开发者

php preg_match to validate twitter username

开发者 https://www.devze.com 2023-01-21 08:55 出处:网络
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:

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

精彩评论

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