Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore case using boost::regex_search

How do you use boost::regex_search with the ignore case flags or constants in C++?

Please post an easy example.

Thanks!

like image 943
arturgspb Avatar asked Jun 06 '11 06:06

arturgspb


People also ask

Are regex matches case-sensitive?

By default, the comparison of an input string with any literal characters in a regular expression pattern is case-sensitive, white space in a regular expression pattern is interpreted as literal white-space characters, and capturing groups in a regular expression are named implicitly as well as explicitly.


1 Answers

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);
like image 163
O.C. Avatar answered Oct 23 '22 20:10

O.C.