【发布时间】:2017-08-09 17:03:35
【问题描述】:
我当前的代码是:
#include <iostream>
#include <Poco/Foundation.h>
#include <Poco/RegularExpression.h>
int main()
{
Poco::RegularExpression regex("[A-Z]+\s+[A-Z]+");
Poco::RegularExpression::MatchVec mvec;
constad std::string astring = "ABC\nDEFG";
int matches = regex.match(astring,0,mvec);
std::cout << "Hello World\n";
return 0;
}
我试图匹配的字符串中'\n' 的位置可以是单个空格、多个空格或换行符(因此我使用空白元字符)。
返回的匹配数为零。我需要设置一个标志吗?
【问题讨论】:
-
加倍反斜杠,因为
\s不是字符串文字中可识别的转义序列。 -
这不是 line-end
$的正则表达式吗?
标签: c++ regex pcre poco-libraries