Php preg_match 表示法语字符

Php preg_match for french characters

任何人都可以帮我写一个 preg_match 来验证字母字符和法语重音字符吗?到目前为止我想出了:

'/^[-[:alpha:]\'[:space:],_\/.]{2,30}$/ui'

您可以使用 unicode properties:

preg_match("~[-\p{L}'\s,_/.]{2,30}$~u", $string, $matches);

其中 \p{L} 代表任意字母。