Yes thank you, that's all I need! > -----Ursprüngliche Nachricht----- > Von: Rafael <rsalazar@xxxxxxxxxxxx> > Gesendet: 16.03.06 07:34:15 > An: php-general@xxxxxxxxxxxxx > Betreff: Re: REG-EXPR: Allowing limited number of special chars in usernames > Holger Sunke wrote: > > 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. > > I don't really understand what you need, but... > - how to find out the number of special (non alphanumeric) characters > $alpha = '[a-z0-9]'; > $special_chars = preg_replace("/$alpha+/Xi", '', $string); > * this would replace any alpha-numeric char by... nothing, leaving > the "special chars" only, and strlen() will give you how many are > * beware that you're saying *anything* other than alpha-numeric chars > > - how to match a string that contains less than 3 special chars > * as I said above, strlen() will give you the number of these chars: > $num_special_chars = strlen($special_chars); > > > preg_match('/^[ -~äöüßÄÖÜ]+$/',$string) > > will return TRUE if $string consists enterily of the chars between the > square-brackets. > > I hope this helped a little. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php