re and multiline strings

Lee Harr missive at frontiernet.net
Sat Jul 21 22:02:58 CEST 2001


>>> t = 'aaazbbbycccc\nccccc\n'
>>> p = re.compile('(.*?)z(.*?)y(.*)')
>>> m = p.search(t)
>>> m.group(1)
'aaa'
>>> m.group(2)
'bbb'
>>> m.group(3)
'cccc'
>>> m = p.search(t, re.DOTALL)
>>> m
>>> m = p.search(t, re.MULTILINE)
>>> m
>>> m = p.search(t, re.MULTILINE,re.DOTALL)
>>> m


what I want is:

>>> m.group(1)
'aaa'
>>> m.group(2)
'bbb'
>>> m.group(3)
'cccc\nccccc\n'




More information about the Python-list mailing list