Regex Error Handling?!
eladioventura at hotmail.com
Sun Jan 5 19:40:33 CET 2003
* Fredrik Lundh <fredrik at pythonware.com> [030105 15:39]:
> Eladio Ventura wrote:
> re.search returns a match object if the pattern matches, or None
> if it doesn't match. the "if" statement treats match objects as true
> values, so you can use "if" right away to check for matches:
> for line in lines:
> match = regex.search(line)
> if match:
> print "We got a mismatched line!"
Thanks a lot Frederik! That's exactly what I was looking for.:0)
"Thinking gives you wrinkles!"
Malibu Stacy, the Simpsons
More information about the Python-list