Capture

Capture

Please note: Capture is still under development.

Regular expressions uses round brackets to group sub-expressions. For instance, a(bc)+ matches one "a" followed by one-or-more "bc" sequences. In addition to grouping sub-expressions, the round brackets are also used to capture (e.g. record for later use) the input that matches the sub-expression. If you wish to avoid the capturing, the you need to use the non-capturing variant a(?:bc)+.

BNFA uses round brackets for non-capturing groups. This is how round brackets works in C++. If you wish to capture a sub-expression, then you must specify it explicity with the capture() directive, e.g.

rule r = text("a") >> capture(text("bc")+);

Back-references


MongoDB Logo MongoDB