【问题标题】:Following regex expression does not work with boost regex以下正则表达式不适用于提升正则表达式
【发布时间】:2014-01-30 04:48:13
【问题描述】:

我正在做以下事情

std::string myregex = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"

 boost::regex re;
      re.assign(regex_expr, boost::regex_constants::icase); //Problem - Breaks

关于assign语句可能有什么问题的任何建议

【问题讨论】:

  • 显示的错误是什么?
  • @nhahtdh 抛出异常。

标签: c++ regex boost-regex


【解决方案1】:

一些正则表达式引擎的解析器比其他引擎更挑剔。但是,如果您将 - 放在字符类的末尾,它们通常会正确解析正则表达式。

"^[_A-Za-z0-9+-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"
             ^^

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-01
    • 1970-01-01
    • 2012-07-24
    • 2013-09-08
    • 2019-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多