这是一个新手问题,但我希望我能尽可能清楚地表达我的问题。
我正在尝试在C++中进行模式匹配。
我已经从这里下载了PCRE的Win32版本,并将下载的pcre3.dll和pcreposix3.dll文件放置在Dev-CPP的lib文件夹中(我正在使用Bloodshed Dev-C++ 4.9.9 IDE)。
我还下载了一个pcrecpp.h头文件,并将其放在我正在编写以下代码的相同目录中(实际上不是编写,而是从名为PCRE-Perl Compatible Regular Express的PDF教程中复制示例代码)。
但我无法使它工作。代码如下:
#include <iostream>
#include <string>
#include <pcrecpp.h>
using namespace std;
int main()
{
int i;
string s;
pcrecpp::RE re("(\\w+):(\\d+)");
if (re.error().length() > 0) {
cout << "PCRE compilation failed with error: " << re.error() << "\n";
}
if (re.PartialMatch("root:1234", &s, &i))
cout << s << " : " << i << "\n";
}
当我编译代码时,Dev-C++ 给了我很多错误,包括:"`pcrecpp' 未声明" 和 "RE" 未声明。
我该如何处理下载的文件并解决我的问题?或者是我忽略了一些显而易见的东西吗?