RE Help

byte8bits at gmail.com byte8bits at gmail.com
Fri Sep 21 15:32:03 EDT 2007


> 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!






More information about the Python-list mailing list