Regular Expression Help
-
Hi all. I have the following regular expression pattern that I go t from a book. ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$ The book says this is suppose to validate atleast 1 uppercase, 1 lowercase, 1 digit, no special characters and between 8 and 10 characters. So "hello123" is not valid, but "Hello123" is valid. Unfortunately "Hello 123" or "Hello@123" are also valid, but should be invalid. What is the correct regular expression syntax? Thanks in advance
-
Hi all. I have the following regular expression pattern that I go t from a book. ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$ The book says this is suppose to validate atleast 1 uppercase, 1 lowercase, 1 digit, no special characters and between 8 and 10 characters. So "hello123" is not valid, but "Hello123" is valid. Unfortunately "Hello 123" or "Hello@123" are also valid, but should be invalid. What is the correct regular expression syntax? Thanks in advance
Hi, In my quick testing, this change achived the desired goal (note that the last "." was replaced with "[0-9,a-z,A-Z]". I don't know all the terms used in working with regular expressions, but I suspect that this answer along with the book you are reading will give you an understanding of the situation!
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9,a-z,A-Z]{8,10}$
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek. -
Hi, In my quick testing, this change achived the desired goal (note that the last "." was replaced with "[0-9,a-z,A-Z]". I don't know all the terms used in working with regular expressions, but I suspect that this answer along with the book you are reading will give you an understanding of the situation!
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9,a-z,A-Z]{8,10}$
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.Thanks John. It worked great.:-D