Skip to content

Instantly share code, notes, and snippets.

View jonpfluger's full-sized avatar

Jon Pfluger jonpfluger

View GitHub Profile

Regex Tutorial

Regex is short for regular expression. A regex is a sequence of characters that defines a specific search pattern. They are used to find certain patterns within a string. They can also be used to replace those characters or a sequence of them. Regular expressions can be included in code or search algorithms. They are often used to validate input.

Summary

In this example, we will be looking at the following regular expression which would be used to validate an email address:

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