/************************************************************************/
/* 密码校验 */
/* C++11下没有问题,但是C语言是有问题的 */
/* 错误案例:^[a-zA-Z0-9~!@#$%^&*()_+`\\-={}\\[\\]:\";'<>?,.\\/]{6,20}$
正确案例:^[]a-zA-Z0-9~!@#$%^&*()_+`={}:;'<>?,./\"\[-]{6,20}$
解答:最恶心的匹配有三个字符 []-
- 如果出现在 [] 的开头或结尾,表示匹配字符 ’-’ ,例如 [^-abc] , [-abc] , [abc-] 。注意不能使用 ’\’ 来转义
] 可以出现在中括号中的第一个位置,例如 []abc] 或 [^]abc]
[ 需要转义
*/
bool CommonFunc::CheckPasswordLegal(std::string strPassword, int lengthMin, int lengMax)
{
if (lengMax == 0)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
return StringUtil::StringVerification(strPassword,
StringUtil::format256("^[a-zA-Z0-9~!@#$%^&*()_+`\\-={}\\[\\]:\"