Skip to content

Instantly share code, notes, and snippets.

View brobro10000's full-sized avatar
🎯
Focusing

Hamzah Ullah brobro10000

🎯
Focusing
View GitHub Profile
@brobro10000
brobro10000 / PhoneNumberRegex.md
Last active August 14, 2021 22:22
Phone Number RegEx: Step-by-step breakdown of the MDN Phone Number Regular Expression

MDN's Phone Number Regex

Regular expressions or regex are special sets of developer designed code used for pattern matching purposes in strings. Its purpose is useful in constraining the input of the user to the expected characters (letters and numbers), format (such as an email which includes an @ and .), and length, (such as a zip code, social security number, or a specific regional phone number). These patterns of expected output are useful for avoiding instances of SQL injection attacks, corrupted databases, or mismatched data that may cause the program to no longer function as expected. We will be going into detail on a single regex in this gist.

Summary

The regex expression we'll be looking at is the expression that parses the information of the input and expects a phone number in return. The expressions original source is from MDN Web Docs describing regular expressions. At the bottom, the following code snippet