Date in format dd/mm/yyyy
/^(0?[1-9]|[12][0-9]|3[01])([ /\-])(0?[1-9]|1[012])\2([0-9][0-9][0-9][0-9])(([ -])([0-1]?[0-9]|2[0-3]):[0-5]?[0-9]:[0-5]?[0-9])?$/
Will match dates with dashes, slashes or with spaces (e.g. dd-mm-yyyy dd/mm/yyyy dd mm yyyy), and optional time separated by a space or a dash (e.g. dd-mm-yyyy-hh:mm:ss or dd/mm/yyyy hh:mm:ss).
date,time
Time in 24-hour format
/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/
Match times in 24 hour format
date,time
Date and time in ISO-8601 format
/^(?![+-]?\d{4,5}-?(?:\d{2}|W\d{2})T)(?:|(\d{4}|[+-]\d{5})-?(?:|(0\d|1[0-2])(?:|-?([0-2]\d|3[0-1]))|([0-2]\d{2}|3[0-5]\d|36[0-6])|W([0-4]\d|5[0-3])(?:|-?([1-7])))(?:(?!\d)|T(?=\d)))(?:|([01]\d|2[0-4])(?:|:?([0-5]\d)(?:|:?([0-5]\d)(?:|\.(\d{3})))(?:|[zZ]|([+-](?:[01]\d|2[0-4]))(?:|:?([0-5]\d)))))$/
Will match a valid date and times in the ISO-8601 format, excludes durations.
date,time
HTML tags
/^<([a-z1-6]+)([^<]+)*(?:>(.*)<\/\1>| *\/>)$/
Match opening and closing HTML tags with content between
markup,xml,html
Username
/^[a-zA-Z0-9_-]{3,16}$/
A string between 3 and 16 characters, allowing alphanumeric characters and hyphens and underscores
username,validation
Hex Color Value
/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
RGB hex colors
hex,color
URL Slug
/^[a-z0-9-]+$/
Match valid URL slugs
URL
/^.+@.+$/
Verify that there is an @ symbol with something before it
email,validation
SRC of image tag
/^<\s*img[^>]+src\s*=\s*(["'])(.*?)\1[^>]*>$/
Match the src attribute of an HTML image tag
html,tag,image
URL
/^((https?|ftp|file):\/\/)?([\da-z-]+\.)+([a-z]{2,6})([\/\w \.-]*)*\/?$/
Match URL with optional protocol
url,address,http
IPv4 Address
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
Match IP v4 addresses
tcpip,internet,address
IPv6 Address
/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/
Match IP v6 addresses
tcpip,internet,address
JWT
/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$/
JSON Web Token (encoded)
www
Positive Integer
/^\d+$/
descriptions:Match whole numbers above zero
number
Negative Integer
/^-\d+$/
Match whole numbers below zero
number
Integer
/^-?\d+$/
Match whole numbers, above or below zero
number
Positive number
/^\d*\.?\d+$/
Match integers or floats that are positive
float
Negative number
/^-\d*\.?\d+$/
Match integers or floats that are negative
float
Positive or negative number
/^-?\d*\.?\d+$/
Match integers or floats that are positive or negative
float
Phone number
/^\+?(\d.*){3,}$/
Match phone numbers at least 3 digits long
validation
New line
/[\r\n]|$/
Match new lines within text
text
ID of Youtube video
/https?:\/\/(?:youtu\.be\/|(?:[a-z]{2,3}\.)?youtube\.com\/watch(?:\?|#\!)v=)([\w-]{11}).*/gi
Match the ID of a youtube video URL
video,youtube,url
ID of Youtube Channel
/https?:\/\/(www\.)?youtube.com\/channel\/UC([-_a-z0-9]{22})/i
Match the ID of a youtube channel URL
channel,youtube,url
CSS comment
/\/\*[^*]*\*+([^/*][^*]*\*+)*\//
Match standard CSS comments
css,comment,code
Wordpress shortcodes
/^\[([a-z-_0-9]+)([^\[]+)*(?:\](.*)\[\/\1\]|\s+\/\])$/
Matches opening and closing shortcode tags with content in-between them.
wordpress,shortcodes,markup
U.S./Canadian ZIP/Postal Code
/(^\d{5}(-\d{4})?$)|(^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$)/
Matches US ZIP, ZIP+4, and Canadian Postal Codes
address, postal, zip
UK Postal Code
/^(([gG][iI][rR] {0,}0[aA]{2})|(([aA][sS][cC][nN]|[sS][tT][hH][lL]|[tT][dD][cC][uU]|[bB][bB][nN][dD]|[bB][iI][qQ][qQ]|[fF][iI][qQ][qQ]|[pP][cC][rR][nN]|[sS][iI][qQ][qQ]|[iT][kK][cC][aA]) {0,}1[zZ]{2})|((([a-pr-uwyzA-PR-UWYZ][a-hk-yxA-HK-XY]?[0-9][0-9]?)|(([a-pr-uwyzA-PR-UWYZ][0-9][a-hjkstuwA-HJKSTUW])|([a-pr-uwyzA-PR-UWYZ][a-hk-yA-HK-Y][0-9][abehmnprv-yABEHMNPRV-Y]))) {0,}[0-9][abd-hjlnp-uw-zABD-HJLNP-UW-Z]{2}))$/
Matches all UK postcodes
address, postal, zip
Brazilian ZIP/Postal Code
/^[0-9]{5}-[0-9]{3}$/
Matches BR ZIP/Postal Code
address, postal, zip
Morse Code
/^[.-]{1,5}(?:[ \t]+[.-]{1,5})*(?:[ \t]+[.-]{1,5}(?:[ \t]+[.-]{1,5})*)*$/
Matches valid Morse Code
morse, code
Image shortcode
/\[img\](.*?)\[\/img\]/
Matches the content in between [img][/img]. Useful for making dynamic WYSIWYG editors
img, shortcode, wysiwyg
Brainfuck Code
/^[+-<>.,\[\] \t\n\r]+$/
Matches valid code for a brainfuck program.
brainfuck, code
Semver
/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-((?:0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
Matches valid semantic versioning.
semver,semantic,versioning,version