python regular expression

Andrew Dalke adalke at mindspring.com
Fri Nov 21 18:21:51 EST 2003


eddie:
> Can some one help me with a
> regex that can replace everything before the <HTML> tag with nothing?

>>> pat = re.compile(r"^((?!<HTML).)*", re.IGNORECASE | re.DOTALL)
>>> pat.sub("", "junk\n<HTML>stuff")
'<HTML>stuff'
>>> pat.sub("", "  <html>stuff")
'<html>stuff'
>>>


                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list