#include "Utils.hpp" #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"Replace First 1: " << std::regex_replace(s, wregex(L"\\.\\.\\."), L"!!!", regex_constants::format_first_only) << endl; wcout << L"Replace First 2: " << std::regex_replace(s, wregex(L"\\b...\\b"), L"???", regex_constants::format_first_only) << endl; wcout << L"Replace First 3: " << std::regex_replace(s, wregex(L"b.d"), L"???", regex_constants::format_first_only) << endl; wcout << L"Replace First 4: " << std::regex_replace(s, wregex(L"(\\w+) (\\w+)"), L"$2 $1", regex_constants::format_first_only) << endl; wcout << L"Replace All 1: " << std::regex_replace(s, wregex(L"\\b...\\b"), L"???") << endl; wcout << L"Replace All 2: " << std::regex_replace(s, wregex(L"(\\w+) (\\w+)"), L"$2 $1") << endl; return 0; }