shortest match regexp operator anyone?
Harald Kirsch
kirschh at lionbioscience.com
Thu Jul 12 02:57:01 EDT 2001
Andrew Kuchling <akuchlin at mems-exchange.org> writes:
> Harald Kirsch <kirschh at lionbioscience.com> writes:
> > With non-greedy matching, another approximation is '^.*?<A>B', however
> > this matches 'xx<A>y<A>B', although it should not.
>
> It sounds like you want something similar to the (?> ...) in Perl 5.6.
> Neither SRE nor the current version of PCRE support this, though.
> Personally I'd just code it explicitly, as 'index = s.find('<A>') ; if
> index != -1: # check for B ...'. Wordier, but doesn't require regex
> arcana.
Reading the docs about (?> ...) at
http://www.perldoc.com/perl5.6/pod/perlre.html#DESCRIPTION
I agree to the phrase `regex arcana'. And I don't see how it could
simulate a shortest match.
Thanks,
Harald Kirsch.
--
----------------+------------------------------------------------------
Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?"
LION bioscience | +49 6221 4038 172 | -- Paul Erdös
*** Please do not send me copies of your posts. ***
More information about the Python-list
mailing list