NYCPHP Meetup

NYPHP.org

[nycphp-talk] preg_match and extended ASCII

Jeff Siegel jsiegel1 at optonline.net
Fri Dec 26 09:03:38 EST 2003


Thanks! That worked fine!

Jeff

Daniel Convissor wrote:

> Hi Jeff:
> 
> On Mon, Dec 22, 2003 at 12:59:45PM -0500, Jeff Siegel wrote:
> 
>>I'm using preg_match to verify form data. I'm not sure how to handle 
>>accented characters, e.g., an "e" with an accent as in Mazda Protegé. 
>>Obviously the following pattern ( '/^[a-z0-9()\/\'"|&,. -]{2,55}$/i' ) 
>>doesn't cut it. I had tried [[:alnum:]] but that didn't do it either.
> 
> 
> You can add acceptable foreign character ranges in there.  Putting the 
> following in would allow all foreign chars:  À-ÖØ-öø-ÿ
> 
> But, that may not come through nicely via email.  So, assuming a character 
> set of ISO-8859-1:
>    ORDINAL: 192-214 216-246 248-255
>    HEX:     c0-d6   d8-f6   f8-ff
>    OCTAL:   300-326 330-366 370-377
> 
> All of these provide coverage for case sensitive matches, so is overkill
> for the case insensitive pattern you proposed, but this isn't a big deal.
> 
> You can also put the hex representations in preg using \xhh syntax (so 
> "\xc0" for example) and octals in via \ddd syntax (ie: "\300").
> 
> Enjoy,
> 
> --Dan
> 

-- 
Found on the Simpson's Website:
"Ooooooh, they have the internet on computers now!"




More information about the talk mailing list