I encounter a weird problem when using regex in c++11 (ubuntu 14.4 ,gcc 4.8.2)
#include <iostream>
#include <regex>
using namespace std;
int main()
{
regex r("(abc|aa.*|bb.*)");
cout<<regex_match("bb11",r)<<endl; //return false
cout<<regex_match("aa11",r)<<endl; //return true
cout<<regex_match("abc",r)<<endl; //return true
return 0;
}
while
int main()
{
regex r("(aa.*|bb.*|cc.*)");
cout<<regex_match("bb11",r)<<endl; //return true
cout<<regex_match("aa11",r)<<endl; //return true
cout<<regex_match("abc",r)<<endl; //return false
return 0;
}
I am wondering why "bb11" got different result?