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.
如何匹配以 1 开头且不包含我尝试过的数字 1612 的四位数字
1[0-9]^6[0-9]^1[0-9]^2
但它不起作用
这对你有用吗?
(?!1612)(1[0-9]{3})
你可以试试 :
^1(?!692)[0-9]{3}$
试试这个代码
\\b1(?!612)\\d{3}\\b
String str = ... if (str.matches("1[\\d]{3}") && !"1612".equals(str)) { // good to go }