Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yahoo Username Regex

I need a (php) regex to match Yahoo's username rules:

Use 4 to 32 characters and start with a letter. You may use letters, numbers, underscores, and one dot (.).

like image 496
magicrobotmonkey Avatar asked Oct 03 '08 21:10

magicrobotmonkey


3 Answers

/^[A-Za-z](?=[A-Za-z0-9_.]{3,31}$)[a-zA-Z0-9_]*\.?[a-zA-Z0-9_]*$/

Or a little shorter:

/^[a-z](?=[\w.]{3,31}$)\w*\.?\w*$/i
like image 149
Markus Jarderot Avatar answered Nov 13 '22 13:11

Markus Jarderot


/[a-zA-Z][a-zA-Z0-9_]*\.?[a-zA-Z0-9_]*/

And check if strlen($username) >= 4 and <= 32.

like image 28
Randy Avatar answered Nov 13 '22 13:11

Randy


A one dot limit? That's tricky.

I'm no regex expert, but I think this would get it, except for that:

[A-Za-z][A-Za-z0-9_.]{3,31}

Maybe you could check for the . requirement separately?

like image 33
Joel Coehoorn Avatar answered Nov 13 '22 11:11

Joel Coehoorn