Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
typedef std::pair<bool, std::vector<CString> > REGEX_RET;
// test the return
REGEX_RET reRet = regexObj.exec( testString, RegExPattern, flags );
if( false == reRet.first ) {
// compile likely failed, test reRet.second.size()
// should be non zero
// if compile failed reRet.second[0] will have detailed explanation
//////matching//////////
char* s = "hello world and everyone else}";
if(regex_match(s, regex("([^ ]+) (([^ ]*) )*(.*)") )
{
...matches...
}
/////extracting///////////
char* s = "{hello-world-and-everyone-else}";
char* re = "([^-]+)-([^-]*)-(.*)";
//# $1 $2 $3
cmatch what;
if(regex_match(s, what, regex(re)))
for(int i = 0; i < what.size(); i++)
cout<< " "<< i<< (i ? " <" : " whole string: <")
<< what[i].str()<< ">"<< endl;
/////replacing//////////
char* s;
char* re;
char* fmt;//format
string out;
s = "hello to everyone zzzz";
re = "([h][^\\h]+)|(yyyyy)|(zzzz)";
cout<< "+-----------BOE--------------"<< endl;
fmt = "{\\$1=$1;\\$2=$2;\\$3=$3}\n"
"(?1condition 1 with [$&]\n)"
"(?2condition 2 with [$&]\n)"
"(?3condition 3 with [$&]\n)";
out = regex_replace(string(s), regex(re), fmt, match_default | format_all);
cout<< out;
cout<< "+-----------EOE--------------"<< endl;
re = "(hello) (to) (everyone) (z+)";
fmt = "{$1}{$2}{$3}";
out = regex_replace(string(s), regex(re), fmt, match_default | format_all);
cout<< out<< endl;