Regex problem with multiline matches
Darrell
darrell at dorb.com
Fri Oct 29 15:37:43 EDT 1999
Or
>>> print re.compile( "(?s).*?b(.)").match( "aa\nbb" )
<re.MatchObject instance at 7ff780>
--Darrell
----- Original Message -----
From: Skip Montanaro <skip at mojam.com>
To: Randall Hopper <aa8vb at yahoo.com>
Cc: <python-list at python.org>
Sent: Friday, October 29, 1999 3:20 PM
Subject: Re: Regex problem with multiline matches
>
> >>>> 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...
>
> --
> http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list