vendredi 6 mars 2015

C++ regex character classes [duplicate]


This question already has an answer here:




Trying to create a std::regex object with a []-enclosed character class in C++ I am getting an error:



std::regex re0("\\.");
std::regex re1("a");
std::regex re2("a+");
std::regex re3("a*");
std::regex re4("[az]"); // fails
std::regex re5("[a-z]"); // fails


This results in the following error:



unknown file: Failure
C++ exception with description "regex_error"


I am using gcc version 4.8.2.


The syntax seems correct according to the reference and works in other regex compilers (I tried Python's re and regex101.com). How can I create a regular expression object for a range character class in C++?


Aucun commentaire:

Enregistrer un commentaire