Forum Moderators: coopster

Message Too Old, No Replies

Check string for consecutive alpha numerics

         

artie2004

4:07 am on Apr 8, 2006 (gmt 0)

10+ Year Member



Hi. I need to check that a password does not contain consecutive alpha numerics. i.e., abbcdef
Could someone tell me how to do this? Thanks.

dreamcatcher

6:37 am on Apr 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use the strstr function to check the occurence of something in a string.

$string = 'abbcdef';

if (strstr($string,'bb'))
{
//error
}

dc

coopster

9:03 pm on Apr 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could use a regular expression, too.
$subject = 'abbcdeeeeeefgh'; 
print "$subject<br />\n";
$pattern = '/(\w)\1+/';
$subject = preg_replace($pattern, "$1", $subject);
print "$subject<br />\n";