Regular Expression – Validate Gmail addresses

You did not tell which regex implementation you use.

^[a-z0-9](\.?[a-z0-9]){5,}@g(oogle)?mail\.com$
  • [a-z0-9] first character
  • (\.?[a-z0-9]){5,} at least five following alphanumeric characters, maybe preceded by a dot (see @Daniel’s comment, copied from @Christopher’s answer)
  • g(oogle)?mail gmail or googlemail (see @alroc’s answer)

Probably you will want to use case-insensitive pattern matching, too. (/.../i in JavaScript.)

Leave a Comment

tech