开发者

Ignore case using boost::regex_search

开发者 https://www.devze.com 2023-03-11 18:10 出处:网络
How do you use boost::regex_search with 开发者_如何转开发the ignore case flags or constants in C++?

How do you use boost::regex_search with 开发者_如何转开发the ignore case flags or constants in C++?

Please post an easy example.

Thanks!


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);


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消