Using Arabic characters with ctype_alnum

后端 未结 2 1753
一向
一向 2021-01-22 01:20

I need to allow Arabic usernames on my website which is already using ctype_alnum to validate the username field. When I try to use Arabic usernames,

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 01:44

    You can find all Arabic Characters by using this Regex:

    preg_match("/^[a-zA-Z\p{Cyrillic}0-9\s\-]+$/u", $string);
    

    If the matched length equals the username length it is an arabic username.

提交回复
热议问题