mercredi 25 juillet 2018

regex error when using cpp11 regex

I was trying to verify the complexity of password using std::regex, and get some examples like:

^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,20}$

I translate it into
regex pwd_regex=regex(string("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,20}$"));

But get an exception of regex_error with error code 4 at runtime.

What's wrong? I try other examples in this question , but also failed.

Aucun commentaire:

Enregistrer un commentaire