I've found this topic which only explains how to replace the first regex match. What about some n'th match?
Say I have a string and a regex like these:
std::string str = "fast cast dust crust must last rust";
std::regex expr = " .(a|u)st";
How can I replace, say, the third match with some other sequence? std::regex_replace
allows to replace either all matches or the first one. I'm also thinking about std::regex_iterator
, but still can't figure out how to apply it in this task. What are the most convenient ways to solve the problem?
Aucun commentaire:
Enregistrer un commentaire