need some clarification with preg_match to match password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

need some clarification with preg_match to match password

Post by PHPHelpNeeded »

I am using this pattern I found in the search:

Code: Select all

        $match_result = array();
        $password = "time123456789";
	$result = preg_match('/^([a-zA-Z0-9]{8,32})$/i', $password, $match_result);
I keep getting result == false, and I cannot figure out how to match it properly.

I would also like to have it so you can use special characters like (.~!@#$%^&*), whether they are all upper case or all lower case or mixed it don't matter.

Anyhelp?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: need some clarification with preg_match to match passwor

Post by Celauran »

What is it you're trying to do here?
PHPHelpNeeded
Forum Commoner
Posts: 83
Joined: Mon Nov 17, 2014 8:03 pm

Re: need some clarification with preg_match to match passwor

Post by PHPHelpNeeded »

I trying to find whether the password enter as a subject matches the pattern that would tell me whether the password was entered in a combination of letter(lower or upper) with numbers and special.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: need some clarification with preg_match to match passwor

Post by Celauran »

If you're allowing letters, numbers, and special characters, it might be a lot easier to do an inverse match (ie. make sure it doesn't match disallowed characters)
Post Reply