progs/re.py
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sat, 15 Jun 2013 09:23:18 -0400
changeset 93 4794759139ea
parent 49 re.py@d2c6852ca8da
permissions -rwxr-xr-x
better organised
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)