boost中的正则表达式中的"."是表示任意字符吗?还是除\n字符以外?
理论上来讲,"."表示的是除\n以外的任意字符,但是经过我的测试,好象"."也可以匹配\n?
这是为什么呢?我的程序如下:
.......//次要代码省略
int main(int argc, char* argv[])
{
char str1[MAX_PATH] = {0};
::strcpy(str1, ".");
regex expression(str1);
std::string in;
cmatch what;
while(true)
{
cout << "enter test string" << endl;
char szIn[MAX_PATH*2] = {0};
::strcpy(szIn, "\n");
if(regex_match(szIn, what, expression))
{
for(int i=0;i<what.size();i++)
cout<<"str :"<<what[i].str()<<endl;
}
else
{
cout<<"Error Input"<<endl;
}
}
return 0;
}
上面的程序,执行结果竟然是匹配,而不是想象中的输入“error input”,难道"."也可以匹配\n字符吗?
谢谢