Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression for password validation

can any one help me in creating a regular expression for password validation.

The Condition is "Password must contain 8 characters and at least one number, one letter and one unique character such as !#$%&? "

like image 601
Andromeda Avatar asked Mar 03 '10 09:03

Andromeda


People also ask

What does ?= Mean in RegEx?

?= is a positive lookahead, a type of zero-width assertion. What it's saying is that the captured match must be followed by whatever is within the parentheses but that part isn't captured. Your example means the match needs to be followed by zero or more characters and then a digit (but again that part isn't captured).


1 Answers

^.*(?=.{8,})(?=.*[a-zA-Z])(?=.*\d)(?=.*[!#$%&? "]).*$  ---  ^.*              : Start (?=.{8,})        : Length (?=.*[a-zA-Z])   : Letters (?=.*\d)         : Digits (?=.*[!#$%&? "]) : Special characters .*$              : End 
like image 106
Macmade Avatar answered Oct 11 '22 12:10

Macmade