I can use Xpressive of the Boost library to do some regex replacement like this:
#include <iostream>
#include <boost/xpressive/xpressive.hpp>
void replace(){
std::string in("a(bc) de(fg)");
sregex re = +_w >> '(' >> (s1= +_w) >> ')';
std::string out = regex_replace(in,re,"$1");
std::cout << out << std::endl;
}
What I need is to replace the captured part by the result of a certain transformation function like e.g.
std::string modifyString(std::string &in){
std::string out(in);
std::reverse(out.begin(),out.end());
return out;
}
so the result of the example provided above would be cb gf.
What do you think would be the best approach to realize this?
Thanks in advance!
Use
live example
In documentation there is all about
regex_replacefunction view Desctiption/Requires