
Untitled
By: a guest on
Apr 27th, 2012 | syntax:
None | size: 0.48 KB | hits: 18 | expires: Never
Weird regular pattern behaviour in Python
import re
data = '''component FA_8 is
port( a : in bit_vector(7 downto 0);
b: in bit_vector(7 downto 0);
s: out bit_vector(7 downto 0);
c: out bit);
end component;'''
m = re.search(r'''component +(w+) +is[ n]+
port *[(] +''', data, re.I | re.VERBOSE)
if m:
print m.group()
else:
print "Cant find pattern"
m = re.search(r'''components+(w+)s+iss+
ports*[(]s+''', data, re.I | re.VERBOSE)