[xpressive] "quantifier not expected" exception when using non-capturing group

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. This expression seems to work fine in PowerGREP. JF

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

Eric Niebler wrote:
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 */ ")" );
This gives a "quantifier not expected" exception.
I have found a very simple and safe fix for this problem. The patch is attached to the bug report: http://svn.boost.org/trac/boost/ticket/1035. I'll be updating the .zip in the File Vault in a minute (look for version 1.0.4), but the Vault doesn't seem to be responding at the moment. I'll leave it up to Thomas to decide whether to accept this fix for 1.34.1. It's not a bad bug, but the fix is simple enough and it passes my tests. -- Eric Niebler Boost Consulting www.boost-consulting.com

On Jun 7, 2007, at 4:16 PM, Eric Niebler wrote:
I'll leave it up to Thomas to decide whether to accept this fix for 1.34.1. It's not a bad bug, but the fix is simple enough and it passes my tests.
Patch applied to RC_1_34_0. Can we close the issue? Thomas -- Thomas Witt witt@acm.org

Thomas Witt wrote:
On Jun 7, 2007, at 4:16 PM, Eric Niebler wrote:
I'll leave it up to Thomas to decide whether to accept this fix for 1.34.1. It's not a bad bug, but the fix is simple enough and it passes my tests.
Patch applied to RC_1_34_0. Can we close the issue?
Closed. I'll add a release note. -- Eric Niebler Boost Consulting www.boost-consulting.com
participants (3)
-
Eric Niebler
-
Jean-Francois Bastien
-
Thomas Witt