#include <iostream>
#include <regex>
using namespace std;
int main() {
bool caseInsensitive = true;
char pattern[257] = "\\bword\\b";
pattern[14] = '(';
cout << "Pattern: " << pattern << endl;
try
{
cout << "Flags: " << std::regex_constants::ECMAScript << endl;
std::regex re(pattern, std::regex_constants::ECMAScript);
}
catch (std::regex_error &e)
{
cout << "Caught: " << e.what() << endl;
}
try
{
cout << "Flags: " << (std::regex_constants::ECMAScript | (caseInsensitive ? std::regex_constants::icase : 0)) << endl;
std::regex re(pattern, std::regex_constants::ECMAScript | (caseInsensitive ? std::regex_constants::icase : 0));
}
catch (std::regex_error &e)
{
cout << "Caught: " << e.what() << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cmVnZXg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWJvb2wgY2FzZUluc2Vuc2l0aXZlID0gdHJ1ZTsKCWNoYXIgcGF0dGVyblsyNTddID0gIlxcYndvcmRcXGIiOwoJcGF0dGVyblsxNF0gPSAnKCc7Cgljb3V0IDw8ICJQYXR0ZXJuOiAiIDw8IHBhdHRlcm4gPDwgZW5kbDsKCXRyeQoJewoJCWNvdXQgPDwgIkZsYWdzOiAiIDw8IHN0ZDo6cmVnZXhfY29uc3RhbnRzOjpFQ01BU2NyaXB0IDw8IGVuZGw7CgkJc3RkOjpyZWdleCByZShwYXR0ZXJuLCBzdGQ6OnJlZ2V4X2NvbnN0YW50czo6RUNNQVNjcmlwdCk7Cgl9CgljYXRjaCAoc3RkOjpyZWdleF9lcnJvciAmZSkKCXsKCQljb3V0IDw8ICJDYXVnaHQ6ICIgPDwgZS53aGF0KCkgPDwgZW5kbDsKCX0KCXRyeQoJewoJCWNvdXQgPDwgIkZsYWdzOiAiIDw8IChzdGQ6OnJlZ2V4X2NvbnN0YW50czo6RUNNQVNjcmlwdCB8IChjYXNlSW5zZW5zaXRpdmUgPyBzdGQ6OnJlZ2V4X2NvbnN0YW50czo6aWNhc2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