gpt4 book ai didi

c++ - 与 Boost Xpressive 进行不区分大小写的匹配

转载 作者:行者123 更新时间:2023-11-28 03:12:55 25 4
gpt4 key购买 nike

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

error C2440: 'type cast' : cannot convert from 'const boost::xpressive::detail::modifier_op' to '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;
}

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

最佳答案

尝试使用

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

syntax_options_type(即 boost::xpressive::regex_constants::icase_)不是 match_flag_type(regex_match 的 3 个参数 应该有这个类型)。

关于c++ - 与 Boost Xpressive 进行不区分大小写的匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17877470/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com