Skip to content

Instantly share code, notes, and snippets.

View christianbmartinez's full-sized avatar
♟️
Making moves

Christian Martinez christianbmartinez

♟️
Making moves
View GitHub Profile
@christianbmartinez
christianbmartinez / regex-gist.md
Last active August 13, 2023 18:43
Using regex to detect phone numbers

Using regex to detect phone numbers

Regex, or regular expression, is a sequence of characters that specifies a match pattern in text. Usually, such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation.

Summary

In this tutorial, we will break down how this regular expression:

^(?:\+1\s?)?(?:\(\d{3}\)|\d{3})[-.\s]?\d{3}[-.\s]?\d{4}$