Skip to content

Instantly share code, notes, and snippets.

Created July 11, 2019 22:22
What would you like to do?
using namespace std;
int main() {
string str = ";;";
regex e("([[:w:]]+)@([[:w:]]+)\.com");
//$1 and $2 represents the group 1 and group 2 in the regex
cout <<regex_replace(str, e, "$1 is on $2") << endl;;
//We can add more flags in the regex_replace function
cout << regex_replace(str, e, "$1 is on $2", regex_constants::format_no_copy|regex_constants::format_first_only);
cout<< endl;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment