Backtracking Control
Backtracking is triggered
whenever
part of the pattern fails to match. You can also explicitly trigger
backtracking by calling the
fail
function within a closure. Table 7-8 shows some metacharacters and
built-in rules relevant to backtracking.
Table 7-8. Backtracking controls
Operator |
Meaning |
---|---|
: |
Don’t retry the previous atom; fail to the next earlier atom. |
|
Don’t backtrack over this point; fail out of the
closest enclosing group ( |
|
Don’t backtrack over this point; fail out of the current rule or subrule. |
|
Don’t backtrack over this point; fail out of the entire match (even from within a subrule). |
|
Like |
Get Perl 6 and Parrot Essentials, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.