In JavaScript have code like:
const text = 'starttext <- code1 -> middletext <- code2 -> endtext';
And I want to get:
starttext middletext endtext
First I tried:
text.replace(/<- .+ ->/, '');
But it returns:
starttext endtext
… because it matches:
< ""anything"" >
But I need to match:
< ""anything but >"" >
So I tried negative overhead:
text.replace(/<- (?!->).+ ->/, '');
… but it works only with alphanumeric characters for me.
How can I make it work with ->?