C ++ boost :: regex_match奇怪的行为

泽利德

尝试boost :: regex_match并得到了奇怪的行为。

boost::cmatch what;
std::string fn_re_str = R"(\.sig\|\|([a-zA-Z0-9$]+)\()";
boost::regex fn_re(fn_re_str);
if (boost::regex_match("{var d=a[c];if(d.sig||d.s){var e=d.sig||qt(d.", what, fn_re)) {
    std::cout << what[1] << std::endl;
} else {
    std::cerr << "not found" << std::endl;
}

qt 有望被发现。

在这里找到https://regex101.com/r/iR9rW5/1

为什么boost :: regex_match找不到它?我想念什么吗?

regex_match仅匹配完整输入:文档

⚠重要

注意,仅当表达式与整个输入序列匹配时,结果才为true。如果要在序列中的某个位置搜索表达式,请使用regex_search如果要匹配字符串的前缀,请regex_search与标志match_continuous集一起使用

使用 regex_search

Live On Coliru

#include <boost/regex.hpp>
#include <iostream>

int main() {
    boost::cmatch what;
    std::string fn_re_str = R"(\.sig\|\|([a-zA-Z0-9$]+)\()";
    boost::regex fn_re(fn_re_str);
    if (boost::regex_search("{var d=a[c];if(d.sig||d.s){var e=d.sig||qt(d.", what, fn_re)) {
        std::cout << what[1] << std::endl;
    } else {
        std::cerr << "not found" << std::endl;
    }
}

印刷

qt

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

C ++ regex_match行为

来自分类Dev

C ++无法使regex_match正常工作

来自分类Dev

C ++ regex_match不起作用

来自分类Dev

C ++无法使regex_match正常工作

来自分类Dev

perl regex比c ++ / boost更快

来自分类Dev

复杂的regex_match在C ++中不起作用

来自分类Dev

使用Boost regex C ++进行编译

来自分类Dev

C#中奇怪的Regex行为

来自分类Dev

BOOST Regex全局搜索行为

来自分类Dev

boost :: filesystem :: path :: string()输出的奇怪行为

来自分类Dev

boost::any / any_ostreamable 的奇怪行为

来自分类Dev

尝试在C ++中使用Boost Regex Match从字符串转换为Int时出错

来自分类Dev

尝试在C ++中使用Boost Regex Match从字符串转换为Int时出错

来自分类Dev

为什么C ++ regex_match函数要求在该函数之外定义搜索字符串?

来自分类Dev

在C ++中将PUNICODE_STRING与regex_match一起使用

来自分类Dev

在C ++ Builder中使用boost :: regex提取双引号

来自分类Dev

C ++ boost :: split首先

来自分类Dev

C ++:复制boost :: array

来自分类Dev

无法安装Boost C ++

来自分类Dev

C ++ Boost错误

来自分类Dev

C ++ boost :: split首先

来自分类Dev

C ++ Boost Lambda Cout <<

来自分类Dev

C ++ Boost错误

来自分类Dev

Boost库的C ++线程

来自分类Dev

C ++ Boost Link错误

来自分类Dev

C ++ OstringStream奇怪的行为

来自分类Dev

C ++ io的奇怪行为

来自分类Dev

C ++奇怪的数组行为

来自分类Dev

C ++ io的奇怪行为