#include "stdafx.h"
#include <regex>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
const char *first = "abc";
const char *last = first + strlen(first);
cmatch narrowMatch;
regex rx("a(b?)c");
bool found = regex_match(first, last, narrowMatch, rx);
/
wstring target(L"Hello");
wsmatch wideMatch;
wregex wrx(L"He(l+)o");
if (regex_match(target.cbegin(), target.cend(), wideMatch, wrx))
wcout << L"The matching text is:" << wideMatch.str() << endl;
string target2("Drizzle");
regex rx2(R"(D\w+e)");
found = regex_match(target2.cbegin(), target2.cend(), rx2);
/
const wchar_t* target3 = L"2014-04-02";
wcmatch wideMatch2;
wregex wrx2(LR"(\d{4}(-|/)\d{2}(-|/)\d{2})");
if (regex_match(target3, wideMatch2, wrx2))
{
wcout << L"Matching text: " << wideMatch2.str() << endl;
}
return 0;
}
#include <regex>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
const char *first = "abc";
const char *last = first + strlen(first);
cmatch narrowMatch;
regex rx("a(b?)c");
bool found = regex_match(first, last, narrowMatch, rx);
/
wstring target(L"Hello");
wsmatch wideMatch;
wregex wrx(L"He(l+)o");
if (regex_match(target.cbegin(), target.cend(), wideMatch, wrx))
wcout << L"The matching text is:" << wideMatch.str() << endl;
string target2("Drizzle");
regex rx2(R"(D\w+e)");
found = regex_match(target2.cbegin(), target2.cend(), rx2);
/
const wchar_t* target3 = L"2014-04-02";
wcmatch wideMatch2;
wregex wrx2(LR"(\d{4}(-|/)\d{2}(-|/)\d{2})");
if (regex_match(target3, wideMatch2, wrx2))
{
wcout << L"Matching text: " << wideMatch2.str() << endl;
}
return 0;
}