Boost logo

Boost Users :

From: emarkp (mping_at_[hidden])
Date: 2002-08-16 12:10:49


--- In Boost-Users_at_y..., "John Maddock" <john_maddock_at_c...> wrote:
> > I sent this originally to James Maddock, but realized this is
> > probably a better place to post it.
>
> Sorry it took me a while to get around to it.

No need to apologize. I'm greatful for the library you provided to
the community!

> I have an answer for you, but I don't think you're going to like it:
> it comes down to how the "leftmost longest" rules are applied:
>
> what's happening here is that $1 is being matched, but it's matching
> the null string just before the \" (at character 26 I think it was),
> the alternative (the one you expected), would have matched starting
> at character 27 (just one to the right of the \"). So the match
> found is in some sense "better" (further to the left) that the one
> you expected. I think I'm going to have to switch to perl matching
> rules so I can stop explaining this... :-)

Drat. I thought that might be it after reading the docs, but I
figured that the expression "? would also match leftmost longest (that
is, a single " is better than the null string). Also, I thought that
by putting a non-capturing group (?:"?) around the expression, this
would leftmost-longest match the ". And yet it didn't.

(I also tried "* and "{0,1} etc.)

Sigh. I *really* did read the docs before emailing. :)

> A simpler solution to your problem is to use a + quantifier rather
> than a *, so that it can't match the null string:

Unfortunately, the match can be empty, hence we couldn't use +.

But thanks for the reply, and for the library!


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net