Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-06-06 13:05:43


Jean-Francois Bastien wrote:
> Here is a simplification of my expression:
> sregex expression = sregex::compile(
> /* 1 */ "^("
> /* 2 */ "c[^\r\n]*(?:\r?\n|\r)"
> /* 3 */ "(?:"
> /* 4 */ "(?!c)"
> /* 5 */ "[^\r\n]*(?:\r?\n|\r)"
> /* 6 */ ")*"
> /* 7 */ ")"
> );
>
> Basically: match lines starting with a "c" and the line that follow,
> until another line starting with a "c" is found.
>
> This gives a "quantifier not expected" exception. Changing line 3 to a
> normal group solves the problem. Changing lines 2 and 5's groups to
> normal groups also solves the problem.

Yes, it's a bug. This is a hard one to hit, too. It happens when:

- The quantifier applies to a group
- The group is non-capturing
- The first element within the non-capturing group is something that
cannot be quantified, such as a zero-width assertion; eg., (?!c)

I've already fixed this on HEAD and added a test. The fix to the RC is
more involved. I'll look into it. I do NOT believe this problem to be
serious enough for 1.34.1, though. It happens quite rarely, and there is
a work-around.

Thanks for the report.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

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