help in converting perl re to python re
Sybren Stuvel
sybrenUSE at YOURthirdtower.com.imagination
Fri Mar 3 05:54:09 EST 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 = regexp.search(line)
will result in 'sometext</tag1><tag1>othertext'
Sybren
--
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