Skip to content

Instantly share code, notes, and snippets.

@TheOarsman
TheOarsman / Regex Tutorial: Matching an Email.md
Last active February 6, 2024 17:46
A brief tutorial of a Regex, specifically for Matching an Email

Regex Tutorial: Matching an Email

According to MDN Web Docs, Regular Expressions, or Regex for short, are powerful patterns used to match character combinations in strings. These patterns are composed of simple and special characters, including uppercase and lowercase letters, numbers, and special symbols.

Summary

In this tutorial, we'll explore how to use Regex to effectively match and validate email addresses. Below, you'll find the Regex pattern for matching an email:

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