Error using Regex

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>
using namespace 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;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
#include<regex>
#include<string>
using namespace 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->str() << endl;
        ++it;
    }

    return 0;
}
just to be sure, you're not using gcc, are you?
I'm using MingW 4.7.1, it does work with Regex right?
> I'm using MingW 4.7.1, it does work with Regex right?

No. GNU libstdc++ implementation of regex is completely broken.

Use boost::regex instead.
Topic archived. No new replies allowed.