为什么boost::regex_match总是返回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

很明显,这里必须匹配,但此代码仍然返回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;
int main(){

cout
regex\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
是最简单的方法。)谢谢,谢谢,