我只想允许上面提到的特殊字符。
我试过这个
private final Pattern hasSpecialChar = Pattern.compile("[!@#$%^&*]");
if (!hasSpecialChar.matcher(password).find()) {
return "String allows only !@#$%^&* special characters";
}
但它也允许其他特殊字符。
任何人都可以帮助我创建一个合适的正则表达式。
烙印99
BIG阳
饮歌长啸
相关分类