与Boost Xpressive不区分大小写

时间:2013-07-26 09:17:27

标签: c++ boost boost-xpressive

我无法获得regex_match函数来查找不区分大小写的匹配项。即使boost::xpressive::regex_constants::icasedefined并且我使用了强制转换(因此Xpressive的icase方法没有歧义),我得到编译错误(VS2010):

  

错误C2440:'type cast':无法从'const boost :: xpressive :: detail :: modifier_op'转换为'boost :: xpressive :: regex_constants :: match_flag_type'

要重现的一些代码:

#include <stdio.h>
#include <boost/xpressive/xpressive.hpp>

int main(){
    std::string str("FOO");
    boost::xpressive::sregex re = boost::xpressive::sregex_compiler().compile("foo");
    bool result = regex_match(str,re,(boost::xpressive::regex_constants::match_flag_type)boost::xpressive::regex_constants::icase);
    if(result){
        std::cout << "Match!";
    }else{
        std::cout << "No match!";
    }
    return 0;
}

你知道问题可能是什么吗?

1 个答案:

答案 0 :(得分:2)

尝试使用

boost::xpressive::sregex re = boost::xpressive::sregex_compiler().
compile("foo", boost::xpressive::icase);

syntax_options_type(即boost::xpressive::regex_constants::icase_)不是match_flag_typeregex_match的3个参数应该具有此类型。)

相关问题