I'm trying to use named subexpressions to replace multiple patterns in the input string using boost::regex_replace and named subexpressions.
I use the following code:
std::string s="Sun Fun Gun Tic Tac Toe ;$!";
boost::regex expr("(?<from1>.un)|(?<from2>[:;!])"); //Throws the error
std::string fmt("(?'from1'nm)(?'from2'sp)");
std::string s2 = boost::regex_replace(s,expr,fmt,boost::match_default|boost::format_all);
std::cout<<s2<<std::endl;
However, when run thos throws the following error:
terminate called after throwing an instance of 'boost::regex_error'
what(): Invalid preceding regular expression
Aborted
Please guide as to what I could be doing wrong?