2
I wonder why the regular expressions I’ve written aren’t giving match (marrying) correctly.
The expressions are as follows::
User name that must be unique and cannot contain special characters (
%-$_#@
, for example), numbers or spaces, with the exception of endpoint.Example of valid user name:
jair.anderson
orjairanderson
Password must have at least 8 digits, at least 1 uppercase character and at least 1 non-alphabetic character (for example:
!$#%
)
Regular expression for user name:
Pattern regexUsername = Pattern.compile("[._^a-z0-9_\\._]");
Regular expression for password:
Pattern regexPassword = Pattern.compile("[^!$#%].+");
Could someone tell me why they don’t function as expected?
How can I validate these rules by regular expression? And why is the expression I made wrong?
– Anderson Souza
Anderson, please click [Edit] below the question and clarify the problem... I was even going to include this last comment of yours that I think is important and I was also going to change the title to be more descriptive, the problem is that I don’t understand your first sentence, wouldn’t it be "For some reason I don’t know, this expression DOESN’T validate the way I need it."???
– brasofilo
I’m sorry I didn’t ask the question more clearly, but I fixed it, see if you can better understand my problem.
– Anderson Souza