Closed User4martin closed 10 months ago
Do all / most engines support \1 inside group1 ? it sounds scary. maybe it's rare feature.
If they support \1 at all, then they supported it nested too.
ECMA handles it different (independent of nested or not)
Given (?: (?:\1|\d) (\w) )*
In the first loop the capture 1 (\w)
has not yet been maatched.
\1
in the first iteration. But may match it in the 2nd iteration.\1
in the first iteration.Same holds true in the nested case. Which really is no different, from a users view. It only is different for the implementation, because the new match must be written in one go only when the )
is reached, so the last match is valid until the next is fully avail.
A back-ref
\1
matches the same literal text as was matched by the most recent successful capture of the group.That is, if the group is matched in a loop, then it will be the text matched in the most recent iteration.
But
The
\1
is within the group 1.https://regex101.com/r/sstaLI/1
In TRegExpr it does not.