gpt4 book ai didi

c++ - 使用 boost::regexp 忽略大小写

转载 作者:太空狗 更新时间:2023-10-29 19:44:04 28 4
gpt4 key购买 nike

<分区>

奇怪的是,谷歌拒绝回答这样简单的问题:
如何使 boost::regexp 不区分大小写?

这是我的:

static const boost::regex bad_words("(?:^|.* )(f(?:uc|a)k(?:i[ng]{1,2})?|bitch(?:es|iz)?)(?:$| .*)");   //reduced to the english ones

当然,我也想过滤大写的坏词。这就是我匹配它们的方式:

//std::string ms; - chat messsage
//boost::match_results<std::string::const_iterator> results; - prewious regexp results
else if(boost::regex_match(ms, results2, bad_words)) { //
std::stringstream msg;
msg<<"Avoid bad words! Word '"<<results2[1]<<"' is banned!";
this->whisper(results[1], msg.str()); //name, message
}

那么,不敏感的正则表达式还有其他功能吗?或者另一个正则表达式对象?或者修饰符 i 可用?

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