#include <iostream>
#include <regex>
#include <string>
int main(int argc, char * argv[])
{
std::string myString("abcdef");
std::smatch myMatches;
std::regex myRegex("(a)(b)(c)(d)(e)(f)");
std::cout << std::regex_replace(myString, myRegex, "$6-$5-$4-$3-$2-$1")
<< std::endl;
return 0;
}
// Output: f-e-d-c-b-a
Reference: http://www.cplusplus.com/reference/regex/regex_replace/
Tuesday, August 29, 2017
C++11: Regex: Replacements
You can do regex replacements. Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment