Boost C++ Libraries: Ticket #2165: regex_search match but regex_match is not filled https://svn.boost.org/trac10/ticket/2165 <blockquote> <p> Hi, </p> </blockquote> <blockquote> <p> I face a problem with the regex_search function. If a piece of the subject match the pattern, and the matched string isn't at start of subject, then regex_search return true but the match_results is empty. </p> </blockquote> <blockquote> <p> I attach a test case source. </p> </blockquote> <blockquote> <p> Sorry for my english, I'm French ;) </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2165 Trac 1.4.3 mickael@… Tue, 05 Aug 2008 00:31:40 GMT attachment set https://svn.boost.org/trac10/ticket/2165 https://svn.boost.org/trac10/ticket/2165 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">regex-bug.cpp</span> </li> </ul> <p> Test case for the problem. </p> Ticket John Maddock Tue, 05 Aug 2008 10:56:48 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2165#comment:1 https://svn.boost.org/trac10/ticket/2165#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> I believe this is a misunderstanding of how regular expressions work: if the expression is [a-z]* then it is perfectly legal to match a zero-length string if the * operator <em>repeats zero times</em>. So for example [a-z]* matched against the string " abc " can find 4 matches: </p> <ul><li>the zero length string at the start of the " abc ". </li><li>the string "abc". </li><li>the zero length string after the "c". </li><li>the zero length string at the end of " abc ". </li></ul><p> When a zero length string is matched, then sub_match::first == sub_match::second and sub_matched::matched == true. </p> <p> Probably you meant to use [a-z]+ as the regular expression? </p> <p> If this doesn't clarify the issue, or if I've misunderstood, please reopen the ticket. </p> <p> HTH &amp; bonjour, John Maddock. </p> Ticket mickael@… Tue, 05 Aug 2008 17:45:37 GMT <link>https://svn.boost.org/trac10/ticket/2165#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2165#comment:2</guid> <description> <blockquote> <p> Bonjour :) </p> </blockquote> <blockquote> <p> You're right, I misused regex_search. I correct my code to increment the start iterator when first == end, and add a test start != end before regex_search. </p> </blockquote> <blockquote> <p> Even Boost::regex stress me a lot, its approach is great. </p> </blockquote> <blockquote> <p> Thanks for your fastness ! </p> </blockquote> </description> <category>Ticket</category> </item> </channel> </rss>