twitter用户名的正则表达式 [英] Regular expression for twitter username
问题描述
我需要一个javascript正则表达式来匹配Twitter用户名。
I need a javascript regular expression to match twitter usernames.
用户在注册时输入用户名,所以我不想分散他们的注意力错误通知太多。因此,我需要表达式匹配有效的用户名,如果他们在用户名之前有@,那么。
The username is entered by the user while signing up, so I don't want to distract them with too many error notifications. Because of that, I need the expression to match valid usernames regardles if they have the @ before the username or not.
Twitter用户名可以包含拉丁字符,下划线和数字,唯一的限制是最长可达15个字符。 (但我需要正则表达式匹配16个字符,以防有人在用户名之前输入@。)
Twitter usernames can contain latin characters, underscores and numbers, and the only limitation is the can be up to 15 characters long. ( but I need the regex to match 16 characters as well, in case someone enters the @ before the username ).
推荐答案
这个应该这样做:
^ @?(\ w){1,15} $
这篇关于twitter用户名的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!