I want to match all lines in a test report, which contain words 'Not Ok'. Example line of text :
'Test result 1: Not Ok -31.08'
I tried this:
filter1 = re.compile("Not Ok")
for line in myfile:
if filter1.match(line):
print line
which should work according to http://rubular.com/, but I get nothing at the output. Any idea, what might be wrong? Tested various other parameters, like "." and "^Test" , which work perfectly.
if "Not Ok" in line:? - Tim Pietzckerre.match()only matches at the start of the string. - Tim Pietzckerre.match("a")is the same asre.search("^a").re.match("Not Ok")will returnTruefor"Not Ok Joe!"andFalsefor"It's Not Ok!". - Tim Pietzcker