1

On page 1056 in the 4th edition of The C++ Programming language, Stroustrup says the ignoring sub-patterns token is (?, however in boost::regex it is (?:. I suspect Stroustrup might be wrong, can anyone with a copy of the standard say?

aaronman
  • 18,343
  • 7
  • 63
  • 78
Polymer
  • 1,043
  • 11
  • 13

1 Answers1

2

Looks like it's a typo in the book. C++11 goes by ECMA regex syntax which says that ?: creates a non capture group. This information is actually not in the c++ standard, it says.

The regular expression grammar recognized by basic_regex objects constructed with the ECMAScript flag is that specified by ECMA-262, except as specified below.

So there are some exceptions but they don't affect your question. Here is a quote from the EMCA-262

NOTE 1 Parentheses of the form ( Disjunction ) serve both to group the components of the Disjunction pattern together and to save the result of the match. The result can be used either in a backreference (\ followed by a nonzero decimal number), referenced in a replace String, or returned as part of an array from the regular expression matching internal procedure. To inhibit the capturing behaviour of parentheses, use the form (?: Disjunction ) instead.

aaronman
  • 18,343
  • 7
  • 63
  • 78