Boost C++ Libraries: Ticket #858: regex_match throws exception https://svn.boost.org/trac10/ticket/858 <pre class="wiki">Running: MS Windows XP with pack 2, boost_1_33_1, MS VS 2005, VC++ console app, BOOST_REGEX_DYN_LINK; Multi-threaded Debug DLL (/MDd) boost::regex site_url_regex("http(s?)://((\b(?:\d{1,3}\.){3}\d{1,3}\b)|(www(.[a-z0-9]+)+.mydomain.com))"); boost::regex_match("http://www.appwebsite1.mydomain.com", site_url_regex); returns true; (as expected) boost::regex_match("http://www.appwebsite1.mydomain.com/1234", site_url_regex); returns false; (as expected) boost::regex_match("http://www.appwebsite1.mydomain.com/12345678/12345678/", site_url_regex); throws exception, - expected false Thank you, Leonid </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/858 Trac 1.4.3 nobody Wed, 21 Mar 2007 18:13:59 GMT <link>https://svn.boost.org/trac10/ticket/858#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/858#comment:1</guid> <description> <pre class="wiki">Logged In: NO You forgot to escape the backslashes in the reg-ex! </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 22 Mar 2007 10:00:54 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/858#comment:2 https://svn.boost.org/trac10/ticket/858#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=14804 Originator: NO The behaviour is deliberate and by design, there are some Perl-style regular expressions that take effectively "forever" to match. Boost.Regex keeps track of how many states the machine has visited and if the number appears to be growing out of control throws an exception. In this case as well as the \'s needing to be escaped, the problem is with (.[a-z0-9]+)+ which is to all intents and purposes the same as the well known pathological case: (.+)+ I assume you meant to use (\\.[a-z0-9]+)+ so as to match a literal ".", and this would be OK. John Maddock </pre> Ticket