Php – Yahoo Username Regex

phpregexvalidationyahoo

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 (.).

Best Solution

/^[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