Home  >  Article  >  Backend Development  >  javascript - 求个 匹配 微博@ 正则表达式格式?

javascript - 求个 匹配 微博@ 正则表达式格式?

WBOY
WBOYOriginal
2016-06-06 20:31:561028browse

匹配微博 正则表达式格式?

回复内容:

匹配微博 正则表达式格式?

这个支持最长20个字的名字,只要不是空格的都当有效,取出来之后再验证是否有效用户名
/@[^\s]{1,20}/

如果不限长度
/@[^\s]+/

如果用户名只可能是英文下划线和数字
/@[a-z0-9_]+/i

如果还有可能是中文
/@[a-z0-9_\u4E00-\u9FA5]+/i/

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn