Hi List,

I'm trying to match lines in python using the re module.
The end goal is to have a regex which enables me to skip lines which have ok 
and warning in it.
But for some reason I can't get negative lookaheads working, the way it's 
explained in "http://docs.python.org/library/re.html";.

Consider this example:

Python 2.6.4 (r264:75706, Nov  2 2009, 14:38:03) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> line='2009-11-22 12:15:441  lmqkjsfmlqshvquhsudfhqf qlsfh qsduidfhqlsiufh 
>>> qlsiuf qldsfhqlsifhqlius dfh warning qlsfj lqshf lqsuhf lqksjfhqisudfh 
>>> qiusdfhq iusfh'
>>> re.match('.*(?!warning)',line)
<_sre.SRE_Match object at 0xb75b1598>

I would expect that this would NOT match as it's a negative lookahead and 
warning is in the string.


Thanks,


-- 
Jelle Smet
http://www.smetj.net
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to