开发者

php preg_match to validate twitter username

What is the pattern to valid开发者_如何学Pythonate a twitter username using preg_match?


I think greg forgot the "@" that indicates the beginning of a twitter handler:

preg_match("/\@[a-z0-9_]+/i", $username);


Twitter allows you to use letters, numbers, and '_', so

preg_match("/[a-z0-9_]+/i", username)

for a case-insensitive search with at least one character.


Better yet:

preg_match('/^\@[\w]+$/', $value);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜