PHP Regex for human names

前端 未结 4 961
故里飘歌
故里飘歌 2020-12-14 22:58

I\'ve run into a bit of a problem with a Regex I\'m using for humans names.

$rexName = \'/^[a-z\' -]$/i\';

Suppose a user with the name Jür

4条回答
  •  借酒劲吻你
    2020-12-14 23:25

    That's a problem with no easy general solution. The thing is that you really can't predict what characters a name could possibly contain. Probably the best solution is to define an negative character mask to exclude some special characters you really don't want to end up in a name.

    You can do this using:

    $regexp = "/^[^]+$/

提交回复
热议问题