facebook username validation regex pattern
i need a regex 开发者_StackOverflow社区pattern to validate if a string is a valid facebook username?
According to this site...
preg_match('/^[a-z\d.]{5,}$/i', $username);
var pattern=/[~!@#$%^&<>]/;
var name=$username;
var count=0;
if(pattern.test(name) )
{
alert('only characters');
}
if(name.match(/[0-9]/))
{
count++;
if(count>5)
alert('not exceds 5 digits');
}
Well, If you use javascript, I made a package and want to introduce you.
github.com/blue-hope/give-me-profile
you can get the regex like this way:
import { SNSRegex, SNSList } from "give-me-profile";
SNSRegex(SNSList.FACEBOOK_USERNAME)
besides, I configured the regex : /^(?!.*.(?:com|net))[A-Z0-9.]{5,}$/i
精彩评论