Click here to Skip to main content
15,878,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create password which must have one special character one number like this,
How can I make it.
Posted

1 solution

Please check this out:

(?=^.{8,}$)
This part means has 8 more more characters, and the match starts at the start of input.

((?=.*\d)
Means contains a digit.

|(?=.*\W+))
Or contains something that is neither a letter or a digit

(?![.\n])
not starting with a dot or UNIX newline.

(?=.*[A-Z])
Contains at least one capital letter.

(?=.*[a-z])
Contains at least one lowercase letter

.*$
Consists entirely of non-newline characters and the matched group will contain the entire string.

Also check some threads:
Form validating![^]
Here[^]
Here[^]
and Here[^]
 
Share this answer
 
v2
Comments
codeBegin 30-Apr-12 1:29am    
Where to write this?? and how?
Please help
Prasad_Kulkarni 30-Apr-12 1:33am    
In your regular expression,
^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$
this will give you exact result & it must contain: One number, one uppercase and one lowercase letter:
codeBegin 30-Apr-12 1:37am    
It works thank you :)
Prasad_Kulkarni 30-Apr-12 1:41am    
Glad it helps!
Formally 'Accept Solution' if its really helpful.
Sandeep Mewara 30-Apr-12 1:42am    
Mark the solution as an answer. You asked for help and someone solved your issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900