如何使用perl样式内存正则表达式与Boost库匹配
How to use Perl style memory regex matching with Boost library
我正在尝试使用Perl的正则记忆功能,该功能将匹配的文本放入()中的变量$ 1,$ 2 ...有人知道我如何通过Boost做到这一点,也许Boost可以将匹配的文本保存在其他位置?以下代码线说$ 1是不确定的。
boost::regex ex( aaa(b+)aaa, boost::regex::perl );
if(boost::regex_search( line ,ex ))
set_value( $1 ); // Here $1 should contain all the b's matched in the parenthesis
谢谢乔
您将需要使用单独的boost::regex_search
特别是您想要一个在boost::match_results
结构中传递的地方(通过参考)。只要搜索成功。
boost::match_results<std::string::const_iterator> results;
std::string line = ...;
boost::regex ex( "aaa(b+)aaa", boost::regex::perl );
if(boost::regex_search( line ,results, ex ))
set_value( results[1] );
相关文章:
- FindPackageHandleStandardArgs.cmake:137 的 CMake 错误(消息):找不到 Boost (缺少:正则表达式)(找到合适的版本"1.72.0",
- 为什么 Boost:正则表达式没有按预期找到所有结果?
- 使用 boost::regex 从目录中获取带有一些正则表达式的文件名称时出现意外输出
- 我的 Boost 正则表达式与任何内容都不匹配
- 使用boost正则表达式时出现shared_ptr错误
- Boost正则表达式:链接时未定义的引用
- 递归匹配与 boost 正则表达式库
- 提高Boost正则表达式的速度或在C++中使用PCRE
- boost正则表达式中的命名捕获/组列表
- 将 C++11 正则表达式与 gcc 4.8.2 一起使用时会出现奇怪的结果(但适用于 Boost 正则表达式)
- 使用boost正则表达式标记文本
- 使用boost正则表达式提取所有以短划线分隔的数字
- Boost正则表达式不替换正则表达式网站上正确替换的表达式
- 在Arch Linux中使用c++Boost正则表达式库
- 将C++Boost正则表达式转换为Python正则表达式
- 使用boost正则表达式解析文本文件
- 搜索/替换boost正则表达式
- Boost正则表达式拆分未命中最后一个单词
- CGI 不适用于 Boost 正则表达式
- 在c++中使用boost正则表达式匹配从字符串转换为整型时出错