I am trying to implement a program that will take a file, find all the regex matches associated with the document, and concatnate specific matches I want into a single string, which is written onto a file.
import re
import sys
f = open ('input/' + sys.argv[1], "r")
fd = f.read()
s = ''
pattern = re.compile(r'(?:(&#\d*|>))(.*?)(?=(&#\d*|<))')
for e in re.findall(pattern, fd, re.S)
s += e[1]
f.close()
o = open ( 'output' + sys.argv[1], 'w', 0)
o.write(s)
o.close()
However, when I try to run this, I get the following error:
File "./regex.py", line 8
for e in re.findall(pattern, fd, re.S)
If