python regular expression

Peter Hansen peter at engcorp.com
Sat Nov 22 00:59:47 CET 2003


eddieNOSPAM at eddiecentral.net wrote:
> 
> I am trying to edit a bunch of files that are similar. I want to remove all
> the ASP code that appears before the <HTML> tag. Can some one help me with a
> regex that can replace everything before the <HTML> tag with nothing?

stuff = 'whatever ASP blah\nblah <HTML>more blah blah</HTML>maybe even more'
try:
    shortStuff = stuff[stuff.index('<HTML>'):]
except:
    shortStuff = stuff

No regex required...




More information about the Python-list mailing list