Use
std::string modifyString(const smatch& match){
std::string out(match[1]);
std::reverse(out.begin(),out.end());
return out;
}
void replace(){
std::string in("a(bc) de(fg)");
sregex re = +_w >> '(' >> (s1= +_w) >> ')';
std::string out = regex_replace(in, re, modifyString);
std::cout << out << std::endl;
}
In documentation there is all about regex_replace
function view Desctiption/Requires