Holger Sunke wrote:
Hello,
I dont know that much aboput regular expressions and just want to know how to
find out the number of special (non alphanumeric) characters in a string or how to match a string that contains less than 3 special chars.
urrently im using a function
function valid_username($string) {
if(strlen($string)<=16&&strlen($string)>5) {
return(preg_match('/^[ -~äöüßÄÖÜ]+$/',$string));
} else {
return FALSE;
}
}
This allows usernames of 6 to 16 length containing many special chars and German "Umlaute".
But this also allows usernames like "=)/(&%$" what should not be.
So how to limit the number of special chars? This function should just return fals if number of special chars > X
Greets,
Holger Sunke
One thing that comes to my mind would be splitting up the string into
letters, numbers and signs with ereg()/preg() and count each one.
Greets
Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php