Reputation: 345
i need a regex pattern to validate if a string is a valid facebook username?
Upvotes: 9
Views: 9547
Reputation: 3269
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
Upvotes: 0
Reputation: 59
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');
}
Upvotes: 1