Regular expression help

David Lees abcdebl2nonspammy at verizon.net
Fri Jul 18 00:31:32 EDT 2003


Andrew Bennetts wrote:
> On Thu, Jul 17, 2003 at 04:27:23AM +0000, David Lees wrote:
> 
>>I forget how to find multiple instances of stuff between tags using 
>>regular expressions.  Specifically I want to find all the text between a 
> 
>                                                ^^^^^^^^
> 
> How about re.findall?
> 
> E.g.:
> 
>     >>> re.findall('BEGIN(.*?)END', 'BEGIN foo END   BEGIN bar END') 
>     [' foo ', ' bar ']
> 
> -Andrew.
> 
> 

Actually this fails with the multi-line type of file I was asking about.

 >>> re.findall('BEGIN(.*?)END', 'BEGIN foo\nmumble END   BEGIN bar END')
[' bar ']





More information about the Python-list mailing list