开发者_开发知识库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.
精彩评论