Re: RegEx to check for non-Latin characters
| From: | Richard Heyes | Date: | Sat, 15 Nov 2008 09:10:39 +0000 |
| Subject: | Re: RegEx to check for non-Latin characters | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-283318@lists.php.net to get a copy of this message | ||
> For a Form Validation process, I need a function to avoid Latin characters
> to be provided as the first or last name. Since we expect our users to
> enter their personal info in Persian.
>
> Do you know any regular expression to provide this functionality?
> 1) Regex to check whether there are Latin and Numerical characters in a
> string.
> 2) Regex to check whether the string only consists of certain characters.
In a PCRE regex, [\x80-\xFF] will find all extended ASCII chars. Or,
if you wanted all ASCII chars, you could use: [\x00-\xFF] That would
catch space and punctuation as well though. Or you could amend it to
suit. It's in hexadecimal (ie FF == 255)
--
Richard Heyes
HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 1st)