Length-encode a string
JavaScript (ES6), 61 bytes

f=(s,d=2)=&gt;s?d&gt;s.length?s[0]+f(s.slice(1),d-2):'*'+f(s,d*2):s


Recursive function that does the following:


If d is less than or equal to remaining string length divided by 2:

Append * to output and multiply d by 2
Else:

Shift the string and append to output, subtract 1 from d.


See it in action:



f=(s,d=2)=&gt;s?d&gt;s.length?s[0]+f(s.slice(1),d-2):'*'+f(s,d*2):s

input.oninput = e =&gt; output.innerHTML = f(input.value);
&lt;input id="input" type="text"/&gt;
&lt;p id="output"&gt;&lt;/p&gt;