I have the code below this:
#include <string>
#include <regex>
int main(int argc, char const *argv[]) {
std::string s = "_apple_";
std::regex r1("_(\\s|\\S)+_");
std::regex r2("_[\\s\\S]+_");
std::regex r3("_.+_");
std::regex r4("_[pale]+_");
std::smatch sm;
printf("r1:%d r2:%d r3:%d r4:%d\n",
std::regex_match(s, sm, r1),
std::regex_match(s, sm, r2),
std::regex_match(s, sm, r3),
std::regex_match(s, sm, r4));
return 0;
}
output:r1:1 r2:0 r3:1 r4:1
I can not understand why r2 is not match?
Aucun commentaire:
Enregistrer un commentaire