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?
不知道加速,但std::regex
(在TR1和C ++ 11),这是基于加速,不支持命名的子表达式。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.