I'm using Java regex to validate an username. They have to meet the following constraints:
Username can contain alphanumeric characters and/or underscore(_).
Username can not start with a numeric character.
8 ≤ |Username| ≤ 30
I ended up with the following regex:
String regex="^([A-Za-z_][A-Za-z0-9_]*){8,30}$";
The problem is that usernames with length > 30 aren't prevented although the one with length < 8 are prevented. What is the wrong with my regex?