The std::regex_match()
doesn't finish (GCC 5.4.0 20160609, x86_64, Ubuntu 16.04).
But it works in some of online compilers: http://cpp.sh/ is ok, for exemple.
The code tries to match an INI-style section header with a possible "#"-comment.
#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;
}
Build:
g++ -std=c++11 main.cpp -o main
Is there really a problem with the code?
Aucun commentaire:
Enregistrer un commentaire