Boost logo

Boost :

From: Benzinger, Ralph (ralph.benzinger_at_[hidden])
Date: 2004-04-08 09:45:23


> > I noticed that the newest regex version no longer supports
> > non-greedy repeats "+?" in match_posix mode. What was the
> > rationale for this?
>
> It is deliberate, non-greedy repeats don't really fit into the POSIX
> matching philosophy, where repeats are neither greedy not
> non-greedy, rather it's parenthesis that determine what the best match
> is.

John,

I'm not sure I understand what you're saying. A regular expression either (completely) matches a given text, or it doesn't; if we ignore parentheses for a moment, then there's no room for different "matching strategies" (like, say, POSIX or not).

When searching for (i.e., grepping) a regular expression, POSIX states "left-most longest", so it shouldn't be ambiguous to determine the left-most longest match among all possible matches (with parenthesis indices breaking ties), even if the RE contains a non-greedy repeat.

Do you have a specific example at hand why you think non-greedy repeats are inappropriate for POSIX-style greps? Personally, I find it very convenient to write REs like "<b>.*?</b>", especially in POSIX mode.

Ralph


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk