help in converting perl re to python re

Sybren Stuvel sybrenUSE at
Fri Mar 3 11:54:09 CET 2006

Joel Hedlund enlightened us with:
> regexp = re.compile(r"<(tag1)>(.*)</\1>")

I'd go for

regexp = re.compile(r"<(tag1)>(.*?)</\1>")

Otherwise this:

line = "<tag1>sometext</tag1><tag1>othertext</tag1>"
match = 

will result in 'sometext</tag1><tag1>othertext'

The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa

More information about the Python-list mailing list