progs/re.py
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 11 Nov 2013 23:24:38 +0000
changeset 185 ea8b94d4755e
parent 93 4794759139ea
permissions -rwxr-xr-x
added
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)