
I'm probably missing something obivous here.....So please fogive me if it's a basic error.
I am using regex for the first time on MSVC 6 and would like to create a simple function that could pass in a string and an expression to do a regular match on it. I believe I have successfully compiled this library, but I don't understand why either of these simple functions are not working....
bool TestStr (std::string& szExpr, const std::string& szSearch) { bool bResult=false;
boost::regex cExpr(szExpr);
bResult = boost::regex_match(szSearch, cExpr);
return bResult; }
or
bool TestStr2 (std::string& szExpr, std::string& szSearch) { return boost::regex_match(szSearch, boost::regex(szExpr)); }
After debugging these routines, it appears thta the boost::regex declaration fails (at least for the first function) returning a Kernel32.dll exception with some kind of address.
The credit card example implies that the search and the regex example I have observed keeps the regex expressions as constansts inside the function, but I would like to be able to parse in my own string
Questions?
1. Wht doesn't any of the functions work?
I would guess there is an exception being thrown somewhere and not getting caught, try: bool TestStr (const std::string& szExpr, const std::string& szSearch) { bool bResult=false; try{ boost::regex cExpr(szExpr); bResult = boost::regex_match(szSearch, cExpr); } catch(const std::exception & e) { std::cout << e.what() << std::endl; } return bResult; } John.