Skip to content

Instantly share code, notes, and snippets.

@joekir
Created August 7, 2016 02:51
Show Gist options
  • Save joekir/119ea91839646f4fed36a3419227f288 to your computer and use it in GitHub Desktop.
Save joekir/119ea91839646f4fed36a3419227f288 to your computer and use it in GitHub Desktop.
Catastrophic Backtrack Examples
Some samples I collected from sites around the web on this topic.
^(A+)*B
^([a-zA-Z0-9]+\s?)*$
(a+)+b
There seems to be a pretty common theme of
>>> r = re.compile('^(A+)+B$',re.DEBUG)
AT AT_BEGINNING
MAX_REPEAT 1 MAXREPEAT
SUBPATTERN 1
MAX_REPEAT 1 MAXREPEAT
LITERAL 65
LITERAL 66
AT AT_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment