C++ program to check whether string generated by that regular expression
regex_match() -Regular expression matches with string -returns true
if not,return false
#include <iostream>
#include <regex> //header file for regex_match() function
using namespace std;
//driver function
int main()
{
string c = "brainly";
// Here d is an object of regex (regular expression)
regex d("(brain)(.*)"); /* regular expression -brain followed by any character */
// regex_match function matches string a against regex b
if ( regex_match(c, d) )
cout << "String 'c' matches regular expression 'd' \n";
return 0;
}
Output
String 'c' matches regular expression 'd'
If string is matched with the regular expression ,we can say that string can be generated by the regular expression.