[nycphp-talk] preg_match and extended ASCII
Daniel Convissor
danielc at analysisandsolutions.com
Tue Dec 23 15:29:23 EST 2003
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
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
More information about the talk
mailing list