Reputation: 1496
If there is a text like ${placeholder1.${placeholder2}}
, is it possible to have a regular expression to match the text recursively like ${placeholder1.${placeholder2}}
${placeholder2}
Upvotes: 0
Views: 564
Reputation: 17357
No, not using a standard regular expression. This is why it is strongly advised not to use a regex to parse HTML. Perl, PCRE and Ruby support an extended form that will instruct the regex to return to the beginning of the pattern and reevaluate the match. See Regular Expression Recursion for more.
In the general case, I'd write a quick parser to handle this use case using a library like PegJS.
Upvotes: 0