user495208
user495208

Reputation: 345

facebook username validation regex pattern

i need a regex pattern to validate if a string is a valid facebook username?

Upvotes: 9

Views: 9547

Answers (3)

blue-hope
blue-hope

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

gangu
gangu

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

alex
alex

Reputation: 490433

According to this site...

preg_match('/^[a-z\d.]{5,}$/i', $username);

Upvotes: 21

Related Questions