Le std::regex_match()
ne se termine pas (GCC 5.4.0 20160609, x86_64, Ubuntu 16.04).std :: regex boucle infinie avec gcc 5.4
Mais cela fonctionne dans certains compilateurs en ligne: http://cpp.sh/ est ok, par exemple.
Le code tente de faire correspondre un en-tête de section de style INI avec un commentaire "#" possible.
#include <regex>
int main(int argc, char *argv[])
{
std::regex headerPattern("([[:blank:]]*\\[[[:blank:]]*((?:[[:blank:]]*[^[:space:]]+[[:blank:]]*?)+)[[:blank:]]*\\][[:blank:]]*(?:#(?:[^[:space:]]*[[:blank:]]*)*)?)");
std::smatch headerMatch;
std::string l("[Hdr 100] # ------------ 22 22 4444 88888888 333");
return std::regex_match(l, headerMatch, headerPattern) ? 0 : 1;
}
Construire:
g++ -std=c++11 main.cpp -o main
Est-il vraiment un problème avec le code?