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);
精彩评论