I've spent an insane amount of time trying to find the appropriate regEx
to select in a string, only those elements that are enclosed by unescaped
custom delimiters (with delimiters included).
My custom delimiters :
${...}
Example of a string:
This
${ is }
a clear${ and simple}
example${string}
, where {${only}
} only the \${highlighted} parts should be selected.
Expected result:
[ "${ is }" , "${ and simple}" , "${string}" , "${only}" ]
I've been able to define the regular expression to select all the tokens in the string :
/(\${\s?\S+\s?})/g
However I still can't figure out how to ignore the wole ESCAPED item, as well as the extra braket returned in ${result-4}
I've been performing my tests here: https://regex101.com/r/XsQFqS/1
I would apprecciate any kind of help with this.