regex is not a member of std—regex 不是std 的成员

std::regex is part of the C++11 STL, and it's not clear which compiler directives are used by this OJ, it could be they just didn't put the -std=c++11 part.


http://www.cnblogs.com/beita/p/4759425.html

1、这几天,使用c++的regex库写字符串处理程序,编译时出现:

ary support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
regex_std1.cpp: In function ‘int main(int, char**)’:
regex_std1.cpp:8:2: error: ‘regex’ is not a member of ‘std’
……

根据提示使用:

g++ regex_std1.cpp -std=c++0x或

g++ regex_std1.cpp -std=c++11或

g++ regex_std1.cpp -std=gnu++11

进行编译可通过。

2、regex_match与regex_search的一个区别

两者的匹配要求是不一样的,前者需要整个字符串符合正则表达式才返回真,而后者只需要字符串的一部分符合正则表达式即可返回真,

所以注意下面这个匹配,将返回假:

std::regex reg("wang");

std::string s("hello, wang");

regex_match(s, reg); // 返回flase

而,下面返回真:

std::regex reg("wang");

std::string s("hello, wang");

std::smatch sm;  //match_results类, 可选参数

regex_search(s, sm , reg); // 返回真

详情可见:http://blog.csdn.net/helonsy/article/details/6800790

<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(77) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当你在安装某个软件包时出现"xxxxx.whl is not a supported wheel on this platform"的错误信息时,这通常表示你正在尝试安装的软件包不兼容你的操作系统或Python版本。该错误提示说明你正在尝试安装的regex版本与当前平台不兼容。 要解决这个问题,可以尝试以下方法: 1. 检查你的操作系统和Python版本是否与软件包的要求相匹配。你可以查看软件包的文档或官方网站,确认其支持的操作系统和Python版本范围。 2. 如果你的操作系统和Python版本符合要求,但仍然遇到此错误,请尝试更新或升级相应的软件包。你可以使用命令"pip install --upgrade packageName"来更新软件包。 3. 如果更新软件包后仍然出现此错误,可以尝试在官方软件包仓库或第三方库中寻找与你的操作系统和Python版本兼容的替代版本。 请注意,解决此问题可能需要进一步的调查和试验。如果以上方法仍然无法解决问题,建议咨询相关领域的专家或在开发者社区中寻求帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ImportError: No module named ‘regex‘ | 如何安装.whl文件?](https://blog.csdn.net/cat_xing/article/details/112283572)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [安装gensim步骤及遇到的问题](https://blog.csdn.net/X_singing/article/details/104980239)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值