Using the re module (Regular expressions)

Opinderjit bhellao at my-deja.com
Tue Sep 26 10:22:56 EDT 2000


What you have should work, except the change the '^' into a '\n'. Also,
I would add the '?' to <.*>, to make it non-greedy. But, you don't have
to.

>> line = 'Returned-Path: <someuser at somehost>\nRecieved:'
>> s = re.search(r'Return-Path:\s<.*?>\nRecieved:')
>> s.group()
>> 'Returned-Path: <someuser at somehost>\012Received:'


In article <lqog1ci0wh.fsf at light.primis.net>,
  morten at esol.no (Morten W. Petersen) wrote:
> I want to match a string, 'Returned-Path: <someuser at somehost
\nRecieved:'.
>
> Why doesn't re.compile(r'Return-Path:\s<.*>^Recieved:',re.MULTILINE)
return a search object that'll match that line?
>
> Thanks in advance.
>
> -Morten
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list