note 112431 added to function.preg-match
| From: | debpal07 at gmail dot com | Date: | Sun, 16 Jun 2013 09:22:50 +0000 |
| Subject: | note 112431 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195236@lists.php.net to get a copy of this message | ||
// Password Validation
public static function isValidPassword($password)
{
/*
Validation Rule:
1. Password must contain 8-15 alpha-numeric characters without spaces
2. Please use a combination of alphabets, numbers and special characters
(@, $, _, !, ~)
3. There must be at least one alphabet, one number and one special character.
*/
if(strlen($password) >= 8 && strlen($password) <= 15)
{
$patterns = array
(
"/[A-Za-z]{1,}[0-9]{1,}[@\$\_!~]{1,}/",
"/[0-9]{1,}[A-Za-z]{1,}[@\$\_!~]{1,}/",
"/[@\$\_!~]{1,}[0-9]{1,}[A-Za-z]{1,}/",
"/[@\$\_!~]{1,}[A-Za-z]{1,}[0-9]{1,}/",
"/[A-Za-z]{1,}[@\$\_!~]{1,}[0-9]{1,}/",
"/[0-9]{1,}[@\$\_!~]{1,}[A-Za-z]{1,}/"
);
foreach ($patterns as $pattern)
{
if(preg_match($pattern, $password)) return true;
}
}
return false;
}
----
Server IP: 69.147.83.199
Probable Submitter: 117.227.249.145
----
Manual Page -- http://php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/112431
Del: integrated -- https://master.php.net/note/delete/112431/integrated
Del: useless -- https://master.php.net/note/delete/112431/useless
Del: bad code -- https://master.php.net/note/delete/112431/bad+code
Del: spam -- https://master.php.net/note/delete/112431/spam
Del: non-english -- https://master.php.net/note/delete/112431/non-english
Del: in docs -- https://master.php.net/note/delete/112431/in+docs
Del: other reasons-- https://master.php.net/note/delete/112431
Reject -- https://master.php.net/note/reject/112431
Search -- https://master.php.net/manage/user-notes.php