如果您需要一个正则表达式,请尝试:(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)一个简短的解释:(?=.*[a-z]) // use positive look ahead to see if at least one lower case letter exists(?=.*[A-Z]) // use positive look ahead to see if at least one upper case letter exists(?=.*\d) // use positive look ahead to see if at least one digit exists(?=.*\W]) // use positive look ahead to see if at least one non-word character exists我同意SilentGhost,\W可能有点宽泛。我用这样的字符集替换它:( [-+_!@#$%^&*.,?]当然可以添加更多!)