//clang #include #include using namespace std; int main(int argc, char **argv) { // note! HTML is *NOT* parsable with regular expressions // this is just an example if you wanted to try // // regex is just basic_regex regex quotedword(R"##("\w+")##"); // default reg-ex lang is ECMA-262 -- essentially Perl 5 // can also construct with additional arg of reg-ex lang regex qword2(R"##("[[:alpha:]]\+)")##",std::regex_constants::egrep); // options are basic, extended, awk, grep, egrep, ECMAScript // can combine with matching options: // icase = case insenstive // nosubs = do not store sub-exp matchs // optimize = make construction slower to make match faster // collate = character ranges are locale sensitive string s; while(!getline(cin,s).eof()) { if (regex_match(s,quotedword)) cout << "whole string matches" << endl; if (regex_search(s,quotedword)) cout << "substring matches" << endl; string news = regex_replace(s,quotedword,R"("xxxxx")"); cout << news << endl; } }