У меня есть код ниже этого:
#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;
}
вывод: r1: 1 r2: 0 r3: 1 r4: 1
Не могу понять, почему r2 не совпадает?
Моя среда:
Настраивается с помощью: --prefix = / Applications / Xcode.app / Contents / Developer / usr --with-gxx-include-dir = / usr / include / c ++ / 4.2.1
Apple LLVM версия 10.0.0 (clang-1000.11.45.5)
Цель: x86_64-apple-darwin17.7.0
Модель потока: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin.