Skip to content

Instantly share code, notes, and snippets.

View caitlinramsey's full-sized avatar

Caitlin caitlinramsey

View GitHub Profile
@caitlinramsey
caitlinramsey / regex-tutorial-email.md
Last active August 2, 2023 22:11
Regular Expression Tutorial - Matching an Email

Regular Expression - Matching an Email

This tutorial is meant to breakdown the regular expression that would be used to validate an email. It is checking that the basic requirements for an email address are being met. The tutorial is supposed to make it easier for someone to understand why the regex looks the way it does and what each part is checking for.

Summary

Matching an Email - /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/

  • The regex is considered a literal which is why it is wrapped in /.
  • The a-z is stating that the string can contain any lowercase letter between a-z.