Boost C++ Libraries: Ticket #4837: referencing subexpr matches via names asserts https://svn.boost.org/trac10/ticket/4837 <p> I am using named subexpressions. The regex pattern constructs fine and the matching works fine too but when I try to index into the match_results object using the name, an assertion is thrown. </p> <pre class="wiki">#include &lt;boost/regex.hpp&gt; #include &lt;string&gt; #include &lt;iostream&gt; #include &lt;stdio.h&gt; using namespace boost; int main() { std::string str = "for is while"; regex pat("(?&lt;keyword&gt;\\b(for|while)\\b)"); sregex_iterator match_iter(str.begin(), str.end(), pat); sregex_iterator match_end; for (; match_iter != match_end; ++match_iter) { smatch match = (*match_iter); ssub_match keywordMatch = match["keyword"]; if (keywordMatch.matched) { printf("matched a keyword!\n"); } size_t pos = (*match_iter).position((size_t)0); size_t len = (*match_iter)[0].second - (*match_iter)[0].first; std::cout &lt;&lt; pos &lt;&lt; "," &lt;&lt; len &lt;&lt; std::endl; } return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4837 Trac 1.4.3 John Maddock Thu, 11 Nov 2010 16:06:17 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4837#comment:1 https://svn.boost.org/trac10/ticket/4837#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">worksforme</span> </li> </ul> <p> I'm closing this issue as this works for me with Boost-1.44.0. </p> <p> Can you please update your Boost installation to the latest release and try again? If it's still failing for you with Boost-1.44, then please reopen and add your platform/compiler information. Some information on where the assertion is failing would also be a big help. </p> <p> Thanks, John Maddock. </p> Ticket