Using the re module (Regular expressions)
bhellao at my-deja.com
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 = re.search(r'Return-Path:\s<.*?>\nRecieved:')
>> '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
> Why doesn't re.compile(r'Return-Path:\s<.*>^Recieved:',re.MULTILINE)
return a search object that'll match that line?
> Thanks in advance.
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list