progs/catastrophic.py
author Christian Urban <urbanc@in.tum.de>
Sun, 21 Aug 2016 18:15:53 +0200
changeset 411 1aec0e1fda86
parent 93 progs/re.py@4794759139ea
child 420 25bc57b32efa
permissions -rwxr-xr-x
updated catastrophic examples
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/usr/bin/env python
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
import re
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
import sys
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
cn = sys.argv[1]
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
r1 = '((a?){%s})' % cn
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
r2 = 'a{%s}' % cn
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
m = re.match(r1 + r2 , "a" * int(cn)) 
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
d2c6852ca8da added programs and slides
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
print m.group(0)