问题
How do you use boost::regex_search
with the ignore case flags or constants in C++?
Please post an easy example.
Thanks!
回答1:
You need something like this
boost::regex regex("your expression here", boost::regex::icase);
boost::smatch what;
string mystring;
bool search_result = boost::regex_search(mystring.begin(),mystring.end(), what, regex);
回答2:
Or something like this (without setting boost::regex::icase
):
boost::regex regex("(?i)expression");
boost::smatch what;
string mystring;
bool search_result = boost::regex_search(mystring.begin(),mystring.end(), what, regex);
来源:https://stackoverflow.com/questions/6248291/ignore-case-using-boostregex-search