more python3 regex?
Doug OLeary
dkoleary at olearycomputers.com
Sun Sep 11 12:57:49 EDT 2016
Hey
This one seems like it should be easy but I'm not getting the expected results.
I have a chunk of data over which I can iterate line by line and print out the expected results:
for l in q.findall(data):
# if re.match(r'(Name|")', l):
# continue
print(l)
$ ./testies.py | wc -l
197
I would like to skip any line that starts with 'Name' or a double quote:
$ ./testies.py | perl -ne 'print if (m{^Name} || m{^"})'
Name IP Address,Site,
"",,7 of 64
Name,IP Address,Site,
"",,,8 of 64
Name,IP Address,Site,
"",,,9 of 64
Name,IP Address,Site,
"",,,10 of 64
Name,IP Address,Site,
"",,,11 of 64
Name IP Address,Site,
$ ./testies.py | perl -ne 'print unless (m{^Name} || m{^"})' | wc -l
186
When I run with the two lines uncommented, *everything* gets skipped:
$ ./testies.py
$
Same thing when I use a pre-defined pattern object:
skippers = re.compile(r'Name|"')
for l in q.findall(data):
if skippers.match(l):
continue
print(l)
Like I said, this seems like it should be pretty straight forward so I'm obviously missing something basic.
Any hints/tips/suggestions gratefully accepted.
Doug O'Leary
More information about the Python-list
mailing list