Using the re module (Regular expressions)

Dan Schmidt dfan at harmonixmusic.com
Tue Sep 26 13:05:44 EDT 2000


morten at esol.no (Morten W. Petersen) writes:

| 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?

In MULTILINE mode, ^ matches a null substring at the beginning of a
line, but it doesn't consume the newline.  So nothing in your regexp
is actually matching the newline.  Use \n instead of ^.

Additionally, you have inconsistent spellings of 'Return-Path', and
you have 'Received' misspelled, which may also be causing problems.

-- 
                 Dan Schmidt | http://www.dfan.org
Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html



More information about the Python-list mailing list