1

Are named subexpressions supposed to be working with regex ICU wrappers? It looks like they are not. For example the code:

boost::u32regex someRegex = boost::make_u32regex( "(?<subExprName>.*)$" );
boost::match_results<std::string::const_iterator> mr;
if( boost::u32regex_search( "sometext", mr, someRegex ) )
    auto subExpr = mr[ "subExprName" ];

crashes due to de-referencing empty shared pointer. More specifically the pointer to the regex's named sub-expressions is not transferred to mr (the match_result) from the ICU wrapping code. The simple addition:

mr.set_named_subs( someRegex.get_named_subs() );

after successful search()/match() fixes it for me, but this line calls 2 private implementation specific methods, that just happen to be in the public part of the classes. I'm using boost 1.64 right now, but I suspect this is not related to particular version.

Are named subexpressions going "out of fashion" in boost regex, since AFAIK the standard does not have such? That would be bad news for me.

zzz
  • 356
  • 4
  • 9
  • 1
    I don't think they go out of fashion. It sounds like a bug/oversight in relation to u32regex. Consider reporting to the maintainers. What you post here might be enough for a pull request, even. – sehe Jul 15 '17 at 23:06
  • @sehe, thank you, I read some posts while searching for it that got me worried. Reported to boost: https://svn.boost.org/trac10/ticket/13126 – zzz Jul 17 '17 at 00:21

0 Answers0