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.
我想匹配一个至少包含一个字母和一个数字的字母数字字符串。有没有一种简单的方法可以将以下内容组合成一个正则表达式?
strValue.matches("[A-Z0-9]+") && strValue.matches(".*[A-Z].*") && strValue.matches(".*[0-9].*")
使用前瞻断言。
strValue.matches("^(?=.*[A-Z])(?=.*\\d)[A-Z\\d]+$")