I have an ascii file which contains lines beginning with
^[[1m
that I would like to skip. I tried:
import re
f = open('MyFile.txt', 'r')
for line in f.readlines():
if re.match(r'^[[1m',line):
continue
But I get an error message:
re_constants.error: unterminated character set at position 1
As suggested, I tried to use startswith but it doesn't match any line. Instead, escaping ^ and [ characters in the regex works. I had misunderstood that using the raw option r would have make escaping social characters unnecessary. Thx !