Parrot Perl 6 regexes #20

Backtracking control -- tokens

Consider:

"182745909809283949 minus 4" ~~ / \d+ ' plus ' \d+ /

Backtracking the first \d+ can be very inefficient

In Perl 5, we would write something like

/ (?>\d+) plus (?>\d+) /x

In Perl 6, a colon after an expression prevents backtracking into the expression

"182745909809283949 minus 4" ~~ / \d+: ' plus ' \d+: /
Copyright © 2009
http://www.pmichaud.com/2009/pres/