How do I match accented characters with PHP preg?

前端 未结 3 1623
忘了有多久
忘了有多久 2020-12-01 09:32

I’d like to give my users the option to not only fill in letters and numbers, but also “special” letters like the “á”, “é”, etc. However, I do not want them to be able to us

3条回答
  •  醉梦人生
    2020-12-01 10:06

    You could use Unicode character properties to describe the characters:

    /^[\p{L}-]*$/u
    

    \p{L} describes the class of Unicode letter characters.

提交回复
热议问题