代码之家  ›  专栏  ›  技术社区  ›  Grzegorz

std::regex在[duplicate]行的末尾时找不到文本

  •  1
  • Grzegorz  · 技术社区  · 7 年前

    请参见下面的代码:

    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分别)结束该行,它将打印 不匹配?!

    这是带有默认regex标志的CR上的bug还是预期的反应?

    0 回复  |  直到 7 年前
    推荐文章