[PHP] substr_count() and regex

2002-03-17 Thread Gil Disatnik

Hello there,
I am trying to use substr_count() to count the number of Hebrew characters 
in a string,
I tried substr_count($test, /[à-ú]/), but it returns 0 as if it can't 
match the regex I have inserted there, I hoped it will work the same as 
preg_match() that works great (preg_match(/[à-ú]/, $test)) for example 
works just fine, but I guess substr_count() is a bit different...

Is there a way for me to do that? maybe with another similar function? (If 
not I will have to solve it in an ugly while loop that searches for Hebrew 
characters one by one...)

Thank you.



Regards

Gil Disatnik
UNIX system/security administrator.

GibsonLP@EFnet

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Windows NT has detected mouse movement, you MUST restart
your computer before the new settings will take effect, [ OK ]

Windows is a 32 bit patch to a 16 bit GUI based on a 8 bit operating
system, written for a 4 bit processor by a 2 bit company which can
not stand 1 bit of competition.
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-


Re: [PHP] substr_count() and regex

2002-03-17 Thread Bas Jobsen

?
function count_hebrew($string)
{
$i=0;
while(preg_match(/[à-ú]/,$string))
{
$string=preg_replace(/[à-ú]/,,$string,1);
$i++;
}
return $i;
}

$hebrew_characters=??? àhhjúkkk;
$number_of_hebrew_characters=count_hebrew($hebrew_characters);
echo $number_of_hebrew_characters;
?

Op zondag 17 maart 2002 20:15, schreef Gil Disatnik:
 Hello there,
 I am trying to use substr_count() to count the number of Hebrew characters
 in a string,
 I tried substr_count($test, /[à-ú]/), but it returns 0 as if it can't
 match the regex I have inserted there, I hoped it will work the same as
 preg_match() that works great (preg_match(/[à-ú]/, $test)) for example
 works just fine, but I guess substr_count() is a bit different...

 Is there a way for me to do that? maybe with another similar function? (If
 not I will have to solve it in an ugly while loop that searches for Hebrew
 characters one by one...)

 Thank you.



 Regards

 Gil Disatnik
 UNIX system/security administrator.

 GibsonLP@EFnet

 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 Windows NT has detected mouse movement, you MUST restart
 your computer before the new settings will take effect, [ OK ]
 
 Windows is a 32 bit patch to a 16 bit GUI based on a 8 bit operating
 system, written for a 4 bit processor by a 2 bit company which can
 not stand 1 bit of competition.
 -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

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