--- a/progs/catastrophic.py Fri Nov 24 03:10:23 2017 +0000
+++ b/progs/catastrophic.py Fri Nov 24 08:58:11 2017 +0000
@@ -4,8 +4,8 @@
# case of catastrophic backtracking in Python
#
-# regex: (a?){n} a{n}
-# strings: aa...
+# regex: (a*)*b
+# strings: aa...a
#
# call with timing as:
#
@@ -14,11 +14,8 @@
# counter n given on the command line
cn = sys.argv[1]
-# constructing the regex
-r1 = '((a?){%s})' % cn
-r2 = 'a{%s}' % cn
+# calling the matching function
+s = ("a" * int(cn))
+m = re.match('(a*)*b' , s)
-# calling the matching function
-m = re.match(r1 + r2 , "a" * int(cn))
-
-print m.group(0)
+print s