[英]Named Subexpressions error in Boost Regex
I'm trying to use named subexpressions to replace multiple patterns in the input string using boost::regex_replace and named subexpressions. 我正在尝试使用boost :: regex_replace和命名子表达式来使用命名子表达式替换输入字符串中的多个模式。
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: 但是,当运行thos引发以下错误时:
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),这是基于加速,不支持命名的子表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.