PHP Regex validate letters and Spanish accent -
how can add/improvised code spanish accent considered valid in addition normal alphabet (a-z)
i have following in code
public static function isalpha($s){ $reg = "#[^a-z\s-]#i"; $count = preg_match($reg, $s, $matches); return $count == 0; }
as found in answer this question, match accented characters using full letter unicode property \p{l}
. includes regular a-z
characters along accented ones, replace a-z
in expression so:
$reg = "#[^\p{l}\s-]#u";
note use need utf-8 modifier u
after closing delimiter, docs such unicode "character types available when utf-8 mode selected".
Comments
Post a Comment