views:

64

answers:

2

I've read how accented characters might sometimes match [a-z]. What I'd like to know is how I could match a specific accented character. Obviously, preg_match('/[ñ]/', 'ñ') does not work.

+6  A: 

Use the /u modifier. That will enable Unicode for the regexes. http://php.net/manual/en/reference.pcre.pattern.modifiers.php

Jimmie Lin
Thanks! This works on my Ubuntu workstation but, unfortunately, it doesn't work on my teammate's Windows XP workstation.
Nikki Erwin Ramirez
This might be a PHP incompatibility with Windows, not sure.
Jimmie Lin
Hmm. Finally got it to work. Had to simplify the expression to use the shorthand `\w` but with the `/u` modifier: `preg_match('/[\w]/iu', 'ñ');` works!
Nikki Erwin Ramirez
A: 

You can take their codes and match them like \xD0 - heximal sequences if accented symbols are not accepted

FractalizeR