Reputation: 31
How can I match a four digit number starting with 1 and which does not contain the number 1612 I tried
1[0-9]^6[0-9]^1[0-9]^2
but it doesn't work
Upvotes: 2
Views: 308
Reputation: 37843
String str = ...
if (str.matches("1[\\d]{3}") && !"1612".equals(str)) {
// good to go
}
Upvotes: 0