Matching UTF Characters with preg_match in PHP: (*UTF8) Works on Windows but not Linux

后端 未结 3 493
别那么骄傲
别那么骄傲 2020-12-10 07:16

I have a simple regular expression to check a username:

preg_match(\'/(*UTF8)^[[:alnum:]]([[:alnum:]]|[ _.-])+$/i\', $username);

In local t

3条回答
  •  盖世英雄少女心
    2020-12-10 08:10

    Try it by describing the characters by its Unicode character properties:

    preg_match('/^\p{L}[\p{L} _.-]+$/u', $username)
    

提交回复
热议问题