Regex problem with multiline matches

Skip Montanaro skip at mojam.com
Fri Oct 29 15:20:14 EDT 1999


    >>>> print re.compile( "b(.)", re.M ).match( "aa\nbb" )
    None

Randall,

The match method anchors the search at the beginning of the string.  Try the
search method instead:

    >>> print re.compile( "b(.)", re.M ).search( "aa\nbb" )
    <re.MatchObject instance at 8125338>

Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/
847-971-7098   | Python: Programming the way Guido indented...




More information about the Python-list mailing list