Skip to content

Instantly share code, notes, and snippets.

View phechzzz's full-sized avatar

Peyton phechzzz

View GitHub Profile
@phechzzz
phechzzz / regexTutorial.md
Last active January 2, 2024 18:46
Regex Tutorial: Matching an Email

Regex: Matching an Email

Regular expressions are powerful search tools comprised of a sequence of defining characters. With regex, you can search, validate, replace, and extract strings of text based on these defining characters.

Summary

In this tutorial, we will break down a regex used to match an email using the following code snippet:
/^([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,})$/
Going character by character, we will work through this snippet of code to understand how it is defining search parameters. Regular expressions can feel overwhelming at first, but by breaking the code down into different defining groups, we can easily understand how this expression is working.