RE: [PHP-DB] regular expression help
| From: | Matthias Steinböck | Date: | Thu, 24 Jun 2004 17:40:55 +0000 |
| Subject: | RE: [PHP-DB] regular expression help | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-34932@lists.php.net to get a copy of this message | ||
hi!
is this correct: you want to check if there are two letters in the password wich do not surround a digit? if so this is what you need:
<?php
// dies
$password = 'alfgoesswimming';
// dies too
$password = 'a2lf4g2o4e7s9s3w9i0m5m7i0n3g';
// survives
$password = 'a2l5f4g2o4e7s9s3w9i0m5m7i0n3g';
$found = array();
$pattern = '#[a-z_]{2}#i';
if(preg_match_all($pattern, $password, $found)>0) {
die('You must have a number between 2 letters in your password ... 0-9');
} else {
die('password accepted');
}
?>
greez ma