RE: regular expression help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i see... so the pattern you need is

<?php

$atLeast = 2;

$pattern = '#\d{1}#';

if(preg_match_all($pattern, $password, $a) > $atLeast) {
	echo 'password ok; contains at least '.$atLeast.' digits.';
}


hth greez ma


Larry Sandwick wrote:

I would like to make sure that there is at least 1 number in the password ?

// Larry


-----Original Message-----
From: Matthias Steinböck [mailto:grillen@xxxxxxxxxxxxxx] Sent: Thursday, June 24, 2004 1:41 PM
To: php-db@xxxxxxxxxxxxx
Subject: RE: regular expression help


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


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux