Backtracking vs. Non-Backtracking

Some patterns have different behaviour depending on whether the implementation is backtracking or not:

if "abc" ^ (IsP ("a") | IsP ("ab")) & IsP ("c"):
   print "must be backtracking"
else:
   print "must be non-backtracking"

Backtracking is the most common implementation – but non-backtracking often has advantages: efficient, predictable and easier for users.

New Models for Processing Text and XML with Python Sam Wilmott
Slide 23 of 51        www.wilmott.ca