I would like to know why the regular expressions I wrote are not correctly matching.
The expressions are as follows:
User name that must be unique and can not contain special characters ( %-$_#@
, for example), numbers or spaces, except endpoint.
Example of valid username: jair.anderson
or jairanderson
Password must be at least 8 digits long, at least 1 uppercase character and at least 1 non-alphabetic character (for example, !$#%
)
Regular expression for the username:
Pattern regexUsername = Pattern.compile("[._^a-z0-9_\._]");
Regular expression for the password:
Pattern regexPassword = Pattern.compile("[^!$#%].+");
Can anyone tell me why they do not work as expected?