boost::regex_match throws exception
I build boost::regex 1.34 using Borland BDS 2006. Simple regular expresions works fine, but I have problem with this regular expresion: ^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$ if a try to match it with any string longer then 22 bytes, regex throws exception. After some investigations i simplified regular expresion to ^[10+]*@$ and it still throws exception code I use: boost::regex e("^[10+]*@$"); boost::match_resultsstd::string::const_iterator what; if(0 == boost::regex_match(input, what, e, boost::match_default | boost::match_partial)) // here function throw exception { throw std::runtime_error("Invalid data entered - this could not possibly be a valid card number"); } if(what[0].matched) { return true; } return false; Milan Bacik
mildaiv@centrum.cz wrote:
I build boost::regex 1.34 using Borland BDS 2006. Simple regular expresions works fine, but I have problem with this regular expresion: ^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$ if a try to match it with any string longer then 22 bytes, regex throws exception. After some investigations i simplified regular expresion to ^[10+]*@$ and it still throws exception
I can't reproduce with Boost-1.34: please post a complete self contained test case. Also make sure that those \'s are double escaped if they're embedded in code: boost::regex e("^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)+$"); Otherwise the expression does something rather different, and *will* get pathological and throw an exception. HTH, John.
participants (2)
-
John Maddock
-
mildaiv@centrum.cz