Allow back references to refer to a capture that hasn't happened yet ("forward reference").

Fixes https://github.com/boostorg/regex/issues/133.
This commit is contained in:
jzmaddock
2021-10-08 14:51:01 +01:00
parent 732d9755bd
commit 74347b95af
5 changed files with 29 additions and 73 deletions

View File

@ -195,7 +195,11 @@ You can also use the \g escape for the same function, for example:
[[[^\g{one}]][Match whatever matched the sub-expression named "one"]]
]
Finally the \k escape can be used to refer to named subexpressions, for example [^\k<two>] will match
Note that a back reference can also be a forward-reference to a sub-expression that has not yet
been seen - this only really makes sense within a repeat, so for example `(\2two|(one))+` will
match "oneonetwo".
Finally the \k escape can be used to refer to named subexpressions, for example [^\k<two>] will
whatever matched the subexpression named "two".
[h4 Alternation]