regexp

skip at pobox.com skip at pobox.com
Tue Dec 19 16:49:45 EST 2006


    vertigo> i noticed that while matching regexp python tries to match as wide as it's  
    vertigo> possible,
    vertigo> for example:
    vertigo> re.sub("<!--.*-->","",htmldata)
    vertigo> would cut out everything before first "<!--" and last "-->" in the  
    vertigo> document.
    vertigo> Can i force re to math as narrow as possible ?

http://docs.python.org/lib/re-syntax.html

Search for "greedy".

Skip



More information about the Python-list mailing list