I am quite new at python and regex so please bear with me.
I am trying to read in a file, match a particular name using a regex while ignoring the case, and store each time I find it. For example, if the file is composed of Bill bill biLl biLL
, I need to store each variation in a dictionary or list.
Current code:
import re
import sys
import fileinput
if __name__ == '__main__':
print "flag"
pattern = re.compile("""([b][i][l][l])""")
for line in fileinput.input():
variation=set(pattern.search(line, re.I))
print variation.groupdict()
print "flag2"
When ran, the code will return an error: 'NoneType' cannot be iterated (or something along those lines). So how do I store each variation?
Thanks in advance!