Skip to content

Instantly share code, notes, and snippets.

View Arankin7's full-sized avatar

Arankin7

View GitHub Profile
@Arankin7
Arankin7 / regexTut.md
Last active June 23, 2022 16:54
Understanding Regex

What is Regex?

A regex, short for regular expression, is a (seemingly random) string of characters that defines a text search pattern. For instance, you could use a regex to help validate that a string of text is a valid email address. Regex could also be used in an application where you want to set certain rules for when a user chooses a username. Regular expressions are used in search engines and most general purpose programming languages support regex capabilities.

Summary

This regex tutorial will break down a regex that is used to match emails. This can be useful when used with an application where you want validate the users email address. The following string of characters is the aforementioned regex. Don't worry if it looks daunting at first sight. We're going to break this down bit by bit so it is much easier to digest.

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