Trying to figure out how to tell whether a string contains any characters in Hebrew with no luck.
How can this be done?
If the source string is UTF-8 encoded, then the simpler approach would be using \p{Hebrew}
in the regex.
The call also should have the /u
modifier.
= preg_match("/\p{Hebrew}/u", $string)
map of the iso8859-8 character set. The range E0 - FA appears to be reserved for Hebrew.
[\xE0-\xFA]
For UTF-8, the range reserved for Hebrew appears to be 0590 to 05FF.
[\u0590-\u05FF]
Here's an example of a regex match in PHP:
echo preg_match("/[\u0590-\u05FF]/", $string);
The simplest approach would be:
preg_match('/[א-ת]/',$string)
For example,
$strings = array( "abbb","1234","aabbאאבב","אבבבב");
foreach($strings as $string)
{
echo "'$string' ";
echo (preg_match('/[א-ת]/',$string))? "has Hebrew characters in it." : "is not Hebrew";
echo "<br />";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With