Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个密码字段,我希望至少有一个特殊字符、至少一个大写字符和至少一个数字。任何人都可以帮我解决正则表达式模式。
谢谢你
Pattern pwPattern = Pattern.compile("(?=.*[@#$!\"&])(?=.*[A-Z]).*\\d.*");
如果您想允许更多,请在第一个括号内添加更多特殊字符,我只是添加了一些。
像这样使用它:
if (pwPattern.matcher(passWordToTest).matches()) { ... }