正则表达式迭代器最后一个匹配出错

C++语言 码拜 8年前 (2016-09-20) 1088次浏览
#include <iostream>
#include <regex>
using namespace std;
int main() {
string p(“[^c]ei”);
p=”[[:alpha:]]*”+p+”[[:alpha:]]*”;
regex r(p,regex::icase);
string text=”receipt freind theif cei receive”;
for(sregex_iterator it(text.begin(),text.end(),r),end_it;it!=end_it;++it)
cout<<it->str()<<endl;
return 0;
}
运行结果是:
freind
theif
ceive
正确结果应该是:
freind
theif
问题在哪里?
解决方案

1

10

重现不能…
用的什么环境?

5

引用:

用的是dev c++ 5.11,-std=c++11,参考的是c++primer 5th

用vc14的库和NDK 12b的libc++库貌似都是正常的…

3

同,无法重现

1

make clean
make

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明正则表达式迭代器最后一个匹配出错
喜欢 (0)
[1034331897@qq.com]
分享 (0)