Talk:cpp/regex/ecmascript

Usefulness
Currently we're already linking to the ECMAScript spec from cpp/regex/syntax_option_type (granted, that could use being more visible). I believe pages on each supported regex syntax could be useful if they --Cubbi (talk) 08:42, 21 October 2013 (PDT)
 * correct and complete (as written, this page is incomplete: it's missing all the locale-sensitive classes supported by C++ in ECMAScript mode)
 * have small examples or at least prose to illustrate and explain different grammar (otherwise it's no better than following a link to the standard)

PS: I suspect that this page, as written, was strongly influenced by http://www.cplusplus.com/reference/regex/ECMAScript/ or whatever its author used as the source -- it follows exact same layout for the part it covers. It would look better if this wiki followed either the standard or boost.regex, or something of its own --Cubbi (talk) 11:29, 21 October 2013 (PDT)


 * I agree, in its current form the page is not much useful. However, there's indeed not much to lose if we have a well documented and consistent documentation of all supported syntaxes. --P12 04:53, 23 October 2013 (PDT)

Example
This example:

show_matches("zaacbbbcac", "(z)((a+)?(b+)?(c))*");

Is currently confusing because the default compiler gcc 9.2 gets the wrong answer:

input=[zaacbbbcac], regex=[(z)((a+)?(b+)?(c))*]: prefix=[] m[0]=[zaacbbbcac]  m[1]=[z]  m[2]=[ac]  m[3]=[a]  m[4]=[bbb]  m[5]=[c] suffix=[]

Clang 5.0 produces the correct answer:

input=[zaacbbbcac], regex=[(z)((a+)?(b+)?(c))*]: prefix=[] m[0]=[zaacbbbcac]  m[1]=[z]  m[2]=[ac]  m[3]=[a]  m[4]=[]  m[5]=[c] suffix=[]

(cf. m[4])

73.252.173.18 23:40, 20 December 2019 (PST)


 * I added a note to that effect in the example code. The gcc bug is apparently known (see here).
 * The unfortunate part is it's what boost::regex, PCRE, Python, Go, etc. all do - but then they all try to conform to Perl syntax, not ECMA-262.
 * Hadriel (talk) 14:08, 21 December 2019 (PST)