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.

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

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.

How about this?

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

commented: didn't get any matches -1

What does this match? I tried some test strings, but get no matches.

Me either Mr. pritaeas didn't get any matches to what tkdchamp has posted earlier

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.