Skip to content

Instantly share code, notes, and snippets.

@KrystianGraba
Forked from Tristan-Ballin/gist.md
Created November 29, 2022 23:36
Show Gist options
  • Select an option

  • Save KrystianGraba/a93d5c70a2085afb045e55a9e6a53872 to your computer and use it in GitHub Desktop.

Select an option

Save KrystianGraba/a93d5c70a2085afb045e55a9e6a53872 to your computer and use it in GitHub Desktop.
Regex for an email

Matching an Email: A Tutorial

A regex, which is short for regular expression, is a sequence of characters that defines a specific search pattern. When included in code or search algorithms, regular expressions can be used to find certain patterns of characters within a string, or to find and replace a character or sequence of characters within a string. They are also frequently used to validate input.

Summary

I will be teaching you how to make a regex for an email validation and describing which parts of the regex describe what.

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

Table of Contents

Regex Components

Anchors

Quantifiers

OR Operator

Character Classes

Flags

Grouping and Capturing

Bracket Expressions

Greedy and Lazy Match

Boundaries

Back-references

Look-ahead and Look-behind

Author

A short section about the author with a link to the author's GitHub profile (replace with your information and a link to your profile)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment