Skip to content

Instantly share code, notes, and snippets.

View michael-loeffler's full-sized avatar

Michael Loeffler michael-loeffler

View GitHub Profile
@michael-loeffler
michael-loeffler / regex-tutorial.md
Last active April 4, 2023 04:01
Regex Tutorial: Matching an Email Address

Regex Tutorial: Matching an Email Address

This gist will feature the regular expression (regex) used for recognizing email addresses in order to explain the functionality of each of the different components that can be used to build a regex.

Summary

I will be breaking down each component of the following regex to explain, step-by-step, what the individual component can do generally, as well as what is doing specifically for the email address regex. Please note that, in each section below, I will not be covering how the given component interacts with other components. I will cover that at the end of the gist. For now, I will only mention what the given component accomplishes. The regex we will be exploring in this gist is:

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

Table of Contents