dimanche 30 avril 2017

C++ regex_search() does not work with star-quantifier

I'm compiling this on Linux with g++ 5.4.0

string s = "ans42";
smatch result;

if (regex_search(s, result, regex("\\d*")))
    cout << result.str() << endl;

Above does match 42 if I change \\d* to \\d+. But AFAIK both are greedy so both should work! What gives?

Aucun commentaire:

Enregistrer un commentaire