I want validate ID using java regex.
- this ID two parts divided by '-' character.
- left part has fixed 2 capital English letters.
- right part has digits where length of digits between 2 and 5.
Here's the code I've tried:
boolean x=l.matches("(?i)[A-Z]{2}-\\[2-3]");
I used "HT-43" as input. I want to get answer as "YES" but I get "NO".
[A-Z]{2}(that is correct and make sense), you ends your pattern with\\[2-3]that doesn't make sense at all! You have missed something in the regex tutorial or something is missing in the question. Read it one more time, otherwise you will always ask this kind of strange questions.