vendredi 22 mai 2015

regex ok but does not works

This code does not works, why?

std::cmatch result;
std::string str("trucmuch.service\n   Loaded: not-found (Reason: No such file or directory)\n   Active: inactive (dead)... (101)");
std::regex rgx("Loaded:\s+(\S+)(?:\s+\((?:Reason:\s*)?([^)]*)\))?", std::regex::ECMAScript);
std::regex_match(str.c_str(), result, rgx);
qDebug() << result.size();

Display 0 !!

How I can get result[0] and result1 ("not-found", "No such file or directory")?

Test on regex101

Aucun commentaire:

Enregistrer un commentaire