Regex Error Handling?!

Eladio Ventura eladioventura at
Sun Jan 5 19:40:33 CET 2003

* Fredrik Lundh <fredrik at> [030105 15:39]:
> Eladio Ventura wrote:
> 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 =
>     if match:
>         matches.append(
>     else:
>         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 mailing list