I'm currently writing a little program containing some regular expressions and functions using them. I've built the following regular expression:
regex rex {R"(.*)" + s + R"(.*)" + g + R"(.*)"};
where s and g are two strings that contain a word each. These words appear in the string in which I want so match and replace, for example:
string input {"This is the example string."};
So, s might be the word is and g might be example. With the above expression I want to match these, and this works, but if I write
input = regex_replace(input, rex, rep_string);
where rep_string is some other string I want to replace with, it doesn't work anymore. If I print out input, then nothing appears on the screen. What's happening here? How can I fix this?
Aucun commentaire:
Enregistrer un commentaire