1

Below program output is "It is not matching" but ideally it should be "It is matching" ?

#include <iostream>
#include <string>
#include <regex>

using namespace std;
using namespace regex_constants;

int main()

{
    string pattern = "[a]*";
    try {
        regex re(pattern, extended);
        if(regex_match("aaaa", re))
           cout << "It is matching" << endl;
        else
           cout << "It is not matching" << endl; 
    }catch(regex_error &e)
    {
       cout << e.what() << endl;
    }
    return 0;
}
Anirudh Ramanathan
  • 46,179
  • 22
  • 132
  • 191
Gaurav
  • 1,891
  • 1
  • 17
  • 20

1 Answers1

0

Try compiling with Clang

clang++ -std=c++0x -stdlib=libc++ yourfile.cpp

Clang (3.3) supports regexes, GCC doesn't yet.

incises
  • 1,045
  • 9
  • 7