Question: this is my current regex code to validate english & numbers:

```
const CANONICAL_FMT = '[0-9a-z]{1,64}';

public static function isCanonical($str)
{
    return preg_match('/^(?:' . self::CANONICAL_FMT . ')$/', $str);

}

```

Pretty straight forward. Now i want to change that to validate only hebrew, underscore
and numbers. So i changed the code to:

```
public static function isCanonical($str)
{
    return preg_match('/^(?:[\u0590-\u05FF\uFB1D-\uFB40]+|[\w]+)$/i', $str);

} 

```

But it doesn't work. I basically took the hebrew UTF range out of Wikipedia.
What is Wrong here?

Answer: 
I was able to get it to work much more easily, using the `/u` flag and the `\p{Hebrew}` [Unicode character property](http://www.php.net/manual/en/regexp.reference.unicode.php):

```
return preg_match('/^(?:\p{Hebrew}+|\w+)$/iu', $str);

```

Working example: <http://ideone.com/gSlmh>
You need the /u modifier to add support for UTF-8.

Make sure you convert your hebrew input to UTF-8 if it's in some other codepage/character set.