Using the re module (Regular expressions)

Opinderjit bhellao at
Tue Sep 26 16:22:56 CEST 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

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

In article <lqog1ci0wh.fsf at>,
  morten at (Morten W. Petersen) wrote:
> I want to match a string, 'Returned-Path: <someuser at somehost
> 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
Before you buy.

More information about the Python-list mailing list