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 |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access