C++ search "regex operators" with regex -
im using regex in c++ , want regex_search * , + symbols, wont work, cause regex symbols. (using namespace std)
string s = "15 * 12"; regex rx("*"); bool flag = regex_search(s, rx);
and
terminating uncaught exception of type std::__1::regex_error: 1 of *?+{ not preceded valid regular expression.
how can fix that?
you need escape special characters using '\'. if specify in c++ string constant need add 2 '\' "\*".
Comments
Post a Comment