[Tutor] Regular expressions - Ignoring linefeeds

Luke Paireepinart rabidpoobear at gmail.com
Fri Mar 2 20:22:12 CET 2007


Kent Johnson wrote:
> Luke Paireepinart wrote:
>   
>> doug shawhan wrote:
>>     
>>> I've been looking through various sites, but cannot find the magic 
>>> button that allows me to match a string with linefeeds
>>> I'd rather not strip out the linefeeds, then stick them back in. :-)
>>>
>>> I'm attempting something that should be fairly simple:
>>>
>>> snippy = re.compile('Hi there.*Bye there.')
>>>       
>> Your RE is wrong.
>> Refer to http://docs.python.org/lib/re-syntax.html
>> * Causes the resulting RE to match 0 or more repetitions of the 
>> preceding RE, as many repetitions as are possible. ab* will match 'a', 
>> 'ab', or 'a' followed by any number of 'b's.
>>     
>
> The RE that is repeated is . which is the intent.
>   
Yeah, sorry.  I thought there was a space after the ., which wouldn't 
work, right?



More information about the Tutor mailing list