question on pattern
hst at empolis.co.uk
Fri Jun 7 12:06:58 CEST 2002
Ulrich Pfisterer wrote:
> I want to do a pattern match on a string that spans multiple
> lines (c++
> style comments, re.match('(/\*.*?\*/)', filestring)
> If I use the re.findall(pattern, string) method it only finds those
> matches that are on a single line. If I use re.match(pattern, string,
> DOTALL) it spans multiple lines but only finds the first match.
> Any help on this one would be greatly appreciated.
>>> import re
>>> r = re.compile('/\*.*?\*/', re.DOTALL)
>>> t = '/* a \nmulti-line\ncomment*/ /*another comment*/'
['/* a \nmulti-line\ncomment*/', '/*another comment*/']
This message has been checked for all known viruses by the MessageLabs Virus Scanning Service.
More information about the Python-list