Regular expression help

David Lees abcdebl2nonspammy at verizon.net
Thu Jul 17 06:27:23 CEST 2003


I forget how to find multiple instances of stuff between tags using 
regular expressions.  Specifically I want to find all the text between a 
series of begin/end pairs in a multiline file.

I tried:
 >>> p = 'begin(.*)end'
 >>> m = re.search(p,s,re.DOTALL)

and got everything between the first begin and last end.  I guess 
because of a greedy match.  What I want to do is a list where each 
element is the text between another begin/end pair.

TIA

David Lees





More information about the Python-list mailing list