You are viewing a single comment's thread. Return to all comments →
Actually, the contents of [...] are interpreted as literal characters, so your regex will not only match alphanumeric characters, but also [, |, etc.
[...]
Use something like this:
String pattern = "^[A-ZA-z]\\w{7,29}$"
[A-Za-z] matches any uppercase or lowercase letter. \\w matches any alphanumeric or _ character.
[A-Za-z]
\\w
_
Seems like cookies are disabled on this browser, please enable them to open this website
Valid Username Regular Expression
You are viewing a single comment's thread. Return to all comments →
Actually, the contents of
[...]
are interpreted as literal characters, so your regex will not only match alphanumeric characters, but also [, |, etc.Use something like this:
[A-Za-z]
matches any uppercase or lowercase letter.\\w
matches any alphanumeric or_
character.