开发者

Function to prevent special characters in nickname

开发者_开发知识库I've a website where users can register. I would like to prevent all special characters, accents, etc in the nickname (used to login).

I use PHP. How can I do that ?

Edit: Another question, can you give me a regular expression (in PHP) who allow ONLY the 26 letters : abcdefghijklmnopqrstuvwxyz and no more ?

Thanks


$username = preg_replace('/[^a-z]/i', '', $username);

If you really just mean lowercase a-z, remove the i flag.

In response to comment, the regexp becomes [^a-z0-9]


You could use PHP's normalizer functions for that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜