[英]Named Subexpressions error in Boost Regex
我正在嘗試使用boost :: regex_replace和命名子表達式來使用命名子表達式替換輸入字符串中的多個模式。
我使用以下代碼:
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;
但是,當運行thos引發以下錯誤時:
terminate called after throwing an instance of 'boost::regex_error'
what(): Invalid preceding regular expression
Aborted
請指導我可能做錯了什么?
不知道加速,但std::regex
(在TR1和C ++ 11),這是基於加速,不支持命名的子表達式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.