Skip to content

Instantly share code, notes, and snippets.

@Wombattree
Wombattree / regexTutorial.md
Last active December 22, 2022 06:56
A regex tutorial

Regex Tutorial

Determining whether or not a string matches specific criteria is a very common problem in programming, particularly in web development where it's important to ensure that, for instance, user login details fit specific rules. This tutorial will cover a method for ensuring that an input string matches the format for an email.

Summary

This is a quick guide to how regular expressions (regex) work and how they can be used in Javascript. For this tutorial I'll be explaining the regex below:

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