\ n或\ r在行尾时,std :: regex无法找到文本

时间:2019-02-28 23:47:44

标签: c++ regex std

请参见下面的代码:

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是否有错误或预期的反应?

0 个答案:

没有答案