In the next line of input:
{$foo}foo bar \\{$blah1}oh{$blah2} even more{$blah3} but not{$blarg}{$why_not_me}
I am trying to match all instances {$SOMETHING_HERE}that are not preceded by a backslash without a return.
Example:
I want it to fit {$SOMETHING}, but not \{$SOMETHING}.
But I want it to fit \\{$SOMETHING}
Attempts:
All my attempts so far will match what I want, except for the tags next to each other, for example {$SOMETHING}{$SOMETHING_ELSE}
Here is what I have now:
var input = '{$foo}foo bar \\{$blah1}oh{$blah2} even more{$blah3} but not{$blarg}{$why_not_me}';
var results = input.match(/(?:[^\\]|^)\{\$[a-zA-Z_][a-zA-Z0-9_]*\}/g);
console.log(results);
What outputs:
["{$foo}", "h{$blah2}", "e{$blah3}", "t{$blarg}"]
purpose
I want this to be:
["{$foo}", "{$blah2}", "{$blah3}", "{$blarg}", "{$why_not_me}"]
Question
Can someone point me in the right direction?
source
share