scarlex
2013-02-02 23:04:00 +08:00
python的话,直接re.search(pattern, string)就行了~
python code:
--------------------------------------------------------------------
import re
f = open('test.txt', 'r')
s = open('after_re.txt', 'w')
pattern = r'<td rowspan="3" valign="top">.*'
for i in f.readlines():
print i
match = re.search(pattern, i)
try:
mystring = match.group(0)
s.write(mystring)
except:
pass
--------------------------------------------------------------------