Recently I've been trying out some of the regex functions in the C++11 and I know about the regex_search or sregex_search functions but that only works non-iteratively, so I tried using the iterative method but I keep getting error messages. What am I doing wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<iostream>
#include<regex>
#include<string>
usingnamespace std;
int main()
{
std::string example="There are 5 separate files in this folder: namely, josh.txt, you.cmd, we.bat, us.cpp, them.hpp";
std::string ww="[a-z_][a-z0-9_]*\\.[a-z]{1,3}";
regex regss(ww, regex_constants::icase);
sregex_iterator it(example.begin(), example.end(), regss);
sregex_iterator it_end;
while (it!=it_end){
cout<<*it<<endl;
++it;
}
return 0;
}