# HG changeset patch # User Christian Urban # Date 1486551722 0 # Node ID 7cdc6d705f7045612f4edb1a1b21f9b401028ec0 # Parent 4bdf0dedd708986d79025a411b04da6b2e7ba0e9 updated diff -r 4bdf0dedd708 -r 7cdc6d705f70 progs/catastrophic3.py --- a/progs/catastrophic3.py Wed Feb 08 11:01:50 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import re -import sys - -# case of catastrophic backtracking in Python -# -# regex: (a?){n} a{n} -# strings: aa... -# -# call with timing as: -# -# > time ./catastrophic.py 20 - -# counter n given on the command line -cn = sys.argv[1] - -# constructing the regex -r = '(.*)a(.{%s})bc' % cn - -# calling the matching function -#m = re.match(r, "axaybzbc") -m = re.match(r, "a" * 100 + "a" * int(cn) + "bc") - -print m.group(0)