PHP Regex validate letters and Spanish accent
As found in the answer to this question, you could match accented characters using the full Letter Unicode property \p{L}
. That includes regular a-z
characters along with accented ones, so replace a-z
in your expression with this like so:
$reg = "#[^\p{L}\s-]#u";
Note that to use this you need the UTF-8 modifier u
after your closing delimiter, as the docs say such Unicode "character types are available when UTF-8 mode is selected".