I need to check a string with a regex.
the valid strings are for example: ABC0001 or A00023.
There are three parts I have to check:
- So the string should start with a word signs:
[a-zA-Z]{1,} - Then there are min one zero:
[0]{1,} - The third part is a number
\\d+
The whole string may not be longer than 8 signs.
What I tried so far:
String NR_PATTERN = "^([a-zA-Z]{1,}[0]{1,}\\d+){3,8}$";
The problem is, that the regex do not accepts the string: KDS0234
[0]is the same as bare-bones0)?"^([a-zA-Z]{1,}[0]{1,}\\d+){3,8}$";mean([a-zA-Z]{1,}[0]{1,}\\d+)appear 3-8 times, not whole length is 3-8"^(?!.{9})[A-Z]+0+[1-9]\\d*$"