PCRE忽略了C 中的匹配
PCRE ignoring matches in c++
本文关键字:PCRE 更新时间:2023-10-16
我正在尝试与ubuntu中的C 和PCRE正则表达式合作。我几乎安装了与软件相关的所有软件(libpcrepp和类似),但我什至无法匹配最简单的表达式。我的代码,简化:
#include <iostream>
#include <string>
#include <pcrecpp.h>
using namespace std;
int main() {
std::string text, a, b;
text = "Flowers in the forest are darker than in the prairie";
pcrecpp::RE re("forest");
if( re.PartialMatch(text, &a, &b) ) {
std::cout << "match: " << a << b << "n";
}
}
没有错误编译:
g++ t2.cpp -lpcrecpp -o t2
执行时没有结果。有暗示吗?预先感谢。
re.partialMatch(text,&amp; a,b)
只有在正则表达式中至少有两个捕获时,才能返回true,一个用于每个返回参数。由于您的正则表达式中没有捕获("森林"),因此保证partialMatch返回false,无论该模式是否与文本相匹配。
相关文章:
- 为什么 pcre 正则表达式比 c++11 正则表达式快得多
- PCRE忽略了C 中的匹配
- 库中的文件PCRE.H在哪里PCRE-8.37
- PCRE:如何使用pcrecpp获取名称捕获
- 提高Boost正则表达式的速度或在C++中使用PCRE
- Preg匹配所有pcre c++
- C++正则表达式与PCRE表达式一起不工作
- 是否可以构造与 3 个或更多非连续 UTF 代码点匹配的 PCRE UTF-8 正则表达式
- 如何在 C/C++ PCRE 正则表达式中使用 UTF-8 文字字符
- C/C++ PCRE 是否可以匹配 2 个或多个 UTF-8 代码点,这些代码点在 UTF-8 字符串中彼此相距甚远
- 带有 PCRE 库的 Cmake ExternalProject_Add不适用于 NMake 生成器
- 等于 posix 正则表达式 c++ 中的 pcre 正则表达式
- 如何使用Unicode处理PCRE
- pcre不能支持多个子组
- 为什么PCRE静态库在Win和Linux上大小不同
- 如何防止pcre(C库)在一个字符串中失败时继续匹配
- 将Python正则表达式转置为PCRE
- Visual C++ 2012 and PCRE
- 将PCRE中某些字符的总数限制为N
- 使用PCRE库编译错误的c++未定义引用