RE Help

chris.monsanto at gmail.com chris.monsanto at gmail.com
Fri Sep 21 15:50:56 EDT 2007


On Sep 21, 3:32 pm, byte8b... at gmail.com wrote:
> > You'll want to use a non-greedy match:
> > x = re.compile(r"START(.*?)END", re.DOTALL)
> > Otherwise the . will match END as well.
>
> On Sep 21, 3:23 pm, Steve Holden <st... at holdenweb.com> wrote:
>
> > Only if there's a later END in the string, in which case the user's
> > requirements will determine whether greedy matching is appropriate.
>
> > regards
> >   Steve
>
> There will be lots of START END combinations in the data. This is more
> accurate:
>
> sfgdfg*START*dfhdgh*END*dfdgh*START*dfhfdgh*END*dfgsdh*START*sdfhfdhj*END*fdghfdj
>
> The RE should extract the data between each couples of START and END.
>
> Thanks!

You'll want to use my version then. Glad to help!




More information about the Python-list mailing list