Subject: Re: [boost] [regex] Support for Perl's (*SKIP)
From: Sei Lisa (seilisasl_at_[hidden])
Date: 2015-04-19 12:57:06
John Maddock wrote, On 2015-04-19 12:55:
> I've added a bug report for this:
Thank you very much.
> However, in the mean time, there is a much simpler workaround, if you use:
> (?x-s) (?# free spacing, dot doesn't match newline)
> (?://.*+ (?# eat single-line comment text)
> |/\*[\S\s]*?\*/ (?# eat multi-line comment text)
> |"(?:\\.|[^"\n])*+" (?# eat string text)
> ) (?# skip these)
> |\b(foo)\b (?# match this)
> And if $1 matched, then you have what you were looking for, otherwise
> discard. It's not as "neat" as the original, but is no less/more
Isn't that basically the same that I said, just changing the grouping?
>> Without (*SKIP), it can be done only by calling regex::search
>> multiple >> times, using an expression like this:
>> and ignoring every match where group 1 wasn't matched. That's
>> presumed to be slower, and certainly more inconvenient for the
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk