Using regex_search we could check if a string cointains a regular expression.
The function requires in input the string to be searched, a match, and the regular expression.
A match is an object of this class:
template <class Iterator,
class Allocator=std::allocator<sub_match<Iterator> >
A few handy typedefs are available to simplify its usage. In the example we are about to use smatch, a match for a (simple) string.
Here is the example:
string s = "Calls to new must be followed by delete.";
if(regex_search(s, m, reg))
cout << "(new), first expression in the regex, has been found" << endl;