Boost logo

Boost :

Subject: Re: [boost] [regex] Support for Perl's (*SKIP)
From: John Maddock (jz.maddock_at_[hidden])
Date: 2015-04-20 07:14:40

> Isn't that basically the same that I said, just changing the grouping?
Apologies, I misread what you wrote: my bad!
>>> Without (*SKIP), it can be done only by calling regex::search
>>> multiple >> times, using an expression like this:
>>> (?-s)//.*+|/\*[\S\s]*?\*/|"(?:\\.|[^"\n])*+"|(\bfoo\b)
>>> and ignoring every match where group 1 wasn't matched. That's
>>> presumed to be slower, and certainly more inconvenient for the
>>> programmer.
> The match shouldn't be given up if a comment or string is found; the
> programmer needs to keep searching until either there's no match, or
> group 1 is matched. It's what I ended up doing.
> I presumed it would be less efficient because it's creating an
> additional match group per call, and because there's the set-up time and
> function call overhead over the multiple calls that are necessary this
> way. And not sure but it's possible there are more cache misses.
It should be exactly the same - the regex engine is doing *exactly* the
same work either which way. It's true that you exit all the way back to
user-code from the regex engine. I can see that being an issue in Perl
when you're dropping back to interpreted code, but should be a non-issue
in C++ compared to the complexity of doing the regex matching. The
extra capturing group adds a little to the memory allocated inside
match_results, but again, I'd be very surprised if that was detectable.

HTH, John.

Boost list run by bdawes at, gregod at, cpdaniel at, john at