2
私はこの次のプログラムをPythonで持っています。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"
なぜ機能していないのかわかりません。私がport\ *[(]\ *
と規則的なパターンの終わりを変えれば、それは合っています。
うんです。タブであり、スペースではありません。ありがとう! – Dilawar