为什么boost::regex_match总是返回false?
很明显,这里必须匹配,但此代码仍然返回false为什么boost::regex_match总是返回false?,regex,boost,Regex,Boost,很明显,这里必须匹配,但此代码仍然返回false #include <iostream> #include <boost/regex.hpp> using namespace std; using namespace boost; int main() { cout << regex_match("some text", regex("text")) << endl; } #包括 #包括 使用名称空间std; 使用名称空间boost; in
#include <iostream>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main() {
cout << regex_match("some text", regex("text")) << endl;
}
#包括
#包括
使用名称空间std;
使用名称空间boost;
int main(){
coutregex\u-match
必须匹配所有给定的字符序列。请尝试regex\u-search
。regex\u-match
必须匹配所有给定的字符序列。请尝试regex\u-search
。我不知道这个regex\u-match
函数,但它可能使用自动锚定模式^
和$
。尝试使用*text
@sp00m Yes,用regex(“text”)
替换regex(“text”)
也会匹配,因为它涵盖了完整的输入“一些文本”
(regex\u search
是一种简单的方法。)我不知道这个regex\u match
函数,但它可能会用^
和$
自动锚定模式。试试*text
@sp00m是的,用regex(“.text”)
替换regex(“text”)
也会匹配,因为它涵盖了完整的输入“一些文本”
。(regex_search
是最简单的方法。)谢谢,谢谢,