请参见下面的代码:
const std::string line = "myemail@gmail.com";
const std::string egrep = ".*gmail.*";
std::regex txt_regex(egrep.c_str());
if (!std::regex_match(line, txt_regex)) {
std::cout << "Not matched?!" << std::endl;
}
else {
std::cout << "Matched" << std::endl;
}
它将打印出匹配。 但是,如果我以CR或LF(分别为\ r或\ n)结束该行,则会打印不匹配?!
使用默认正则表达式标志的CR是否有错误或预期的反应?