RE Help

chris.monsanto at gmail.com chris.monsanto at gmail.com
Fri Sep 21 15:05:51 EDT 2007


On Sep 21, 2:44 pm, David <wizza... at gmail.com> wrote:
> > data = "asdfasgSTARTpruyerfghdfjENDhfawrgbqfgsfgsdfg"
> > x = re.compile('START.END', re.DOTALL)
>
> This should work:
>
> 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.




More information about the Python-list mailing list