0

Hai everybody,
the string
$password = $request->getParameter('password');

Contains at least 8 characters.
Contains upper and lower case letters.
Contains numbers or other non-alphabetic characters.
What could be the reg ex for the above criteria?

I am creating a check for stronger password .

something like:

if (len(password) >= 8 &&
    contains_lower(password) &&
    contains_upper(password) &&
    contains_number(password)) {
    ...
}

plz help me.

4
Contributors
5
Replies
23
Views
4 Years
Discussion Span
Last Post by masterjiraya
0

strlen() <- count the characters including white space
strToLower() <-forces string to lower case
strToUpper() <-forces string to upper case

0

I don't recommend to use a single regex for all the checks (if that's what you meant). It's much easier to just loop through your string and count what category each character falls in.

-1

How about this?

(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$

Edited by pritaeas: Added markdown.

Votes + Comments
didn't get any matches
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.