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 (.).
/^[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
/[a-zA-Z][a-zA-Z0-9_]*\.?[a-zA-Z0-9_]*/
And check if strlen($username) >= 4 and <= 32.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With