正则表达式 : 6~16位字符,至少包含数字.字母.符号中的2种

正则表达式 : 6~16位字符,至少包含数字.字母.符号中的2种

fun verifyPassWord(string: String): Boolean{
        val regex = "^(?!^(\\d+|[a-zA-Z]+|[~!@#$%^&*?]+)$)^[\\w~!@#$%^&*?]{6,16}$"
        //val regex = "(?!^[0-9]+\$)(?!^[A-z]+\$)(?!^[^A-z0-9]+\$)^.{6,16}\$"
        val pattern = Pattern.compile(regex)
        val matcher = pattern.matcher(string);

        return  matcher.matches()

    }

  

原文地址:https://www.cnblogs.com/changyiqiang/p/15594212.html