#include "Utils.hpp" #include #include #include #include #include #include std::locale utf8loc(std::locale(), new std::codecvt_utf8); using namespace std; int main(int argc, char **argv) { setlocale(LC_ALL, "en_US.UTF-8"); wcout.imbue(utf8loc); wcin.imbue(utf8loc); wstring const s = L"Four score and seven years ago..."; wcout << L"Match 1: " << regex_search(s, wregex(L"s.*e")) << endl; wcout << L"Match 2: " << regex_search(s, wregex(L"\\bs.*e\\b")) << endl; wcout << L"Match 3: " << regex_search(s, wregex(L"s...e")) << endl; wcout << L"Match 4: " << regex_search(s, wregex(L"b.d")) << endl; vector subgroups = Utils::regex_findfirst(wregex(L"(\\w+)\\s*(\\w+)"), s); wcout << L"Find First (with subgroups): " << Utils::to_wstring(subgroups) << endl; subgroups = Utils::regex_findfirst(wregex(L"bad match"), s); wcout << L"Find First (bad match): " << Utils::to_wstring(subgroups) << endl; vector matches = Utils::regex_findall(wregex(L"\\w+"), s); wcout << L"Find All: (matches only)" << Utils::to_wstring(matches) << endl; matches = Utils::regex_findall(wregex(L"bad match"), s); wcout << L"Find All (bad match): " << Utils::to_wstring(matches) << endl; return 0; }