C++ regex_match match_continuous标志与开始子字符串不匹配
C++ regex_match match_continuous flag doesn't match beginning sub-string
我一直在使用regex_match使用下面的示例
string text("* @file my_file.c");
regex exp("\s*\*\s*@file")
if(regex_match(text,exp,regex_constants::match_continuous))
//This doesn't work
我知道regex_match尝试用正则表达式匹配整个文本,但就我在这里阅读的match_continuous标志应该接受从文本开头开始的子字符串。但是我的运气不太好,所以我不得不把我的解决方案转换成这个
string text("* @file my_file.c");
regex exp("^\s*\*\s*@file")
if(regex_search(text,exp))
//This time works
我想问我在第一个例子中做错了什么。我的环境是VS2010。
match_continous
与regex_search
合作
。
std::regex_search(text, exp, std::regex_constants::match_continuous)