RegEx Library - a curated list of useful regular expressions for different programming languages.
The regular expressions below can be used to validate if a string is an email address and to extract email addresses from a string. This validation method however does not guarantee that the emails validated and extracted actually exist.
The regular expressions below can be used to validate if a string is a valid phone number format and to extract a phone number from a string. Please note that this validation can not tell if a phone number actually exists.
The regular expressions below can be used to validate if a string is a valid IP address format and to extract an IP address from a string. Please note that this validation can not tell if an IP address actually exists.
Date regular expressions can be used to validate if a string has a valid date format and to extract a valid date from a string.
URL regular expressions can be used to verify if a string has a valid URL format as well as to extract an URL from a string.
Numbers only (or digits only) regular expressions can be used to validate if a string contains only numbers.
UUID is a 128-bit label used for identifications in computer systems.
This regular expression can be used to validate that a given string contains only characters in it or extract two words from a given string.
ZIP code (US postal code) regular expression can be used to verify if a given string contains a valid ZIP code or extract ZIP code from a string. Supports both 5-digit and 9-digit (ZIP+4) formats.
GUID is an acronym for Globally Unique Identifier and used for resource identification. The term is generally used instead of UUID when working with Microsoft technologies.
Password regular expression can be used to verify that a password provided is strong enough to provide better protection against bot brute force attacks. This method, however, does not guarantee that a password will have enough entropy to be completely safe.
HTML stands for HyperText Markup Language and is used to display information in the browser. HTML regular expressions can be used to find tags in the text, extract them or remove them. Generally, it’s not a good idea to parse HTML with regex, but a limited known set of HTML can be sometimes parsed.
SSN stands for social security number and is issued to US citizens, permanent and temporary residents.
XML stands for Extensible Markup Language and is used for storing arbitrary data. Usually, it’s not a good thing to parse XML with regular expressions, but in certain situations, it can be very helpful to retrieve (scrape) a specific piece of information that you need.
Mac address is a unique identifier assigned to network interface controllers like WiFi routers, Ethernet controllers, etc. It has a format of six groups of 2 hexadecimal digits separated by dash or colon (e.g. 00:00:5e:00:53:af). Mac address regular expression can be used to validate that a certain string contains mac address or extract mac address from a given string.
Usually, it’s a bad idea to validate street addresses using regular expressions (read below). But in some cases it might make sense and here’s a regular expression that can help with that
/