我當前的代碼是:如何匹配Poco :: RegularExpression C++中的「 n」?
#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'是無法識別的轉義序列在字符串文字中。 – nhahtdh
對於正則表達式,不是_line-end_'$'嗎? – user0042