I have regex which uses a look ahead assertion to match strings of the format {{ x }}. The regex is /(?<={{s)[^}s]+(?=s*}})/gm
How can I achieve this without using a look ahead assertion?
I have regex which uses a look ahead assertion to match strings of the format {{ x }}. The regex is /(?<={{s)[^}s]+(?=s*}})/gm
How can I achieve this without using a look ahead assertion?
2
Answers
Try with this:
{{s([^}s]+)s*}}
Your result will be inside the first group (the rules inside
()
)Adding to the other answers, if you want a list of all "x values", you can produce one by repeatedly evaluating
m[1]
, which is the first group, wherem
is one of the matches.The following variants with and without lookaround are equivalent:
The question remains, however: Why do you want to avoid lookarounds?