Help with regular expression

Ulrich Petri ulope at gmx.de
Thu Sep 18 08:35:30 EDT 2003


"anton muhin" <antonmuhin.REMOVE.ME.FOR.REAL.MAIL at rambler.ru> schrieb im
Newsbeitrag news:bkbssb$102f$1 at news.peterlink.ru...
> Stephen Boulet wrote:
>
> > I'm trying to write an RE to match a string that might or might not be
> > ther and everything past it up to another string that might or might not
> > be there and everything past it to a third string that might or might
> > not be there and everything past it.
> >
>
> Try non-greedy wildcards: r'((STRING1.*?)(STRING2.*?)(STRING3.*?))'
>        -           -           -
>

Since you said that each of the three strings might or not be there you
would need:

r'((STRING1.*?)?(STRING2.*?)?(STRING3.*?)?)'

Ciao Ulrich






More information about the Python-list mailing list