JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id="textin" cols="80" rows="10">
START-Hyphens-should-be-replaced-here-01-END
OTHER-no-changes-here-02-WORD
START-Hyphens-should-also-be-replaced-here-03-END
OTHER-no-changes-here-either-04-TEXT
</textarea>
<button onclick="process();">Submit</button>
<pre id="textout">output</pre>
JavaScript
function process() {
var re = /(START.*?)-(.*?END)/g;
var textin = document.getElementById('textin').value;
while (textin.match(re)) {
textin = textin.replace(re, '$1 $2');
}
document.getElementById('textout').textContent = textin;
}