Ignore case using boost::regex_search

戏子无情 提交于 2019-12-23 07:38:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!