Boost C++ Libraries: Ticket #13080: Boost Xpressive ignores capture placeholders https://svn.boost.org/trac10/ticket/13080 <p> This code: </p> <pre class="wiki">#include "boost/xpressive/xpressive.hpp" int main() { using namespace boost::xpressive; cregex scheme = (s1 = +_w) &gt;&gt; "://"; cregex host_ipv6 = (s2 = ('[' &gt;&gt; +(xdigit | ':') &gt;&gt; ']')); cregex uri_re = scheme &gt;&gt; host_ipv6; cmatch m; if( regex_match( "http://[fe::]", m, uri_re ) ) { // [first, last) pair of iterators, with implicit operator string() std::string protocol = m[1]; protocol = protocol; } return 0; } </pre><p> It runs and it matches but protocol will contain empty string. Visual Studio 2015, in debug/release, 32/64bit. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13080 Trac 1.4.3 Eric Niebler Thu, 22 Jun 2017 21:34:32 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/13080#comment:1 https://svn.boost.org/trac10/ticket/13080#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> After the match, <code>m</code> has no sub_matches. It does, however, have nested results that correspond to the nested regexes in <code>uri_re</code>. Please read [^1] for more information. </p> <p> [^1]: <a href="http://www.boost.org/doc/libs/1_64_0/doc/html/xpressive/user_s_guide.html#boost_xpressive.user_s_guide.grammars_and_nested_matches.nested_regexes_and_sub_match_scoping">http://www.boost.org/doc/libs/1_64_0/doc/html/xpressive/user_s_guide.html#boost_xpressive.user_s_guide.grammars_and_nested_matches.nested_regexes_and_sub_match_scoping</a> </p> Ticket Evgeny Yashin <johny5.coder@…> Thu, 22 Jun 2017 22:34:14 GMT <link>https://svn.boost.org/trac10/ticket/13080#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13080#comment:2</guid> <description> <p> Thank you, overlooked indeed. A bit unexpected though. </p> <p> Any way to flatten the matching results? Breaking into set of regexps, here, should be considered as simplifying final expression for human reading, not declaring any recursive grammars. </p> </description> <category>Ticket</category> </item> <item> <author>Evgeny Yashin <johny5.coder@…></author> <pubDate>Thu, 22 Jun 2017 22:36:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13080#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13080#comment:3</guid> <description> <p> Addition, I see that iterating through tree gives the flatten view over nested results, I am mostly about keeping original index based syntax, where s1= .. match will be accessed via m<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> index later on. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Thu, 22 Jun 2017 23:34:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13080#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13080#comment:4</guid> <description> <p> It can't. There could be a 0<sup>th</sup> submatch in two nested regexes. They would stomp each other. The <code>nested_results</code> keeps them separate. </p> </description> <category>Ticket</category> </item> </channel> </rss>