On Fri, Sep 21, 2007 at 12:05:51PM -0700, [EMAIL PROTECTED] wrote regarding Re: RE Help: > > > > > x = re.compile('START(.*)END', re.DOTALL) > > You'll want to use a non-greedy match: > > x = re.compile(r"START(.*?)END", re.DOTALL) > > Otherwise the . will match END as well.
The . will only consume END if there is another END to match later on in the string. And then it's a question of desired fuctionality. If the given string is: "abcdSTARTefgENDxyzENDhijk" do you want to match "STARTefgEND" (in which case you need a non-greedy match r".*?" )? or do you want to match "STARTefgENDxyzEND" (in which case you need a greedy match: r".*" )? Cheers, Cliff -- http://mail.python.org/mailman/listinfo/python-list