Don’t just use it. Understand it.

Regex without the
guesswork.

Test patterns, see their structure, document the tricky parts, and share a durable workspace with your team.

email.regex
/[^@\s]+@[^@\s]+\.[^@\s]+/gm
See the structureBrowser-rendered railroad diagrams
Explain the whyNotes beside every pattern
Share a workspaceOne link your whole team can open
29 practical patterns

A library for the regex you actually write.

01

username

A username is a unique identifier given to accounts in websites and social media

$ pattern/^[a-z0-9_-]{3,15}$/gm
nameslug
02

password

Minimum eight characters, at least one upper case English letter, one lower case English letter, one number and one special character

$ pattern/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/gm
passwordsecretkey
03

email simple

Simple email regex that works most of the times

$ pattern/[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+/gm
emailmailgmail
04

email complicated

Unnecessarily complicated email regex that works "more than" most of the times

$ pattern/(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gm
emailmailgmail
05

phone number

Match a phone number with "-" and/or country code.

$ pattern/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/gmi
phonemobilenumber
06

ip address(ipv4)

Matches an ip address(version 4)

$ pattern/(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/gm
ipipv4
07

ip address(ipv6)

Internet Protocol version 6 (IPv6) is the most recent version of the Internet Protocol. This is used to provide identification for devices in a network.

$ pattern/(([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]))/gm
ipipv6
08

date

Matches a date in the format dd/mm/yyyy , dd-mm-yyyy or dd.mm.yyyy

$ pattern/(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[13-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})/gm
datetodaydd/mm/yyyy
09

ascii

Matches any printable ascii character

$ pattern/[ -~]/gm
asciiunicode
10

url

A valid URL with http/https

$ pattern/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/gm
urlhttphttps
11

ssn

A Social Security number (SSN) is a nine-digit number that the U.S. government issues to all U.S. citizens and eligible U.S

$ pattern/^(?!0{3})(?!6{3})[0-8]\d{2}-(?!0{2})\d{2}-(?!0{4})\d{4}$/gm
ssnnumberid
12

semantic versioning

Match a SemVer as specified in https://semver.org/

$ pattern/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/gm
semverversionsemantic
13

uuid

Hyphen-separated universally unique identifier (UUID)

$ pattern/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gm
uuidguidid
14

jira issue ticket

Hyphen-separated Jira project key and ticket issue number

$ pattern/[A-Z]{2,}-\d+/gm
jirasoftware
15

latitude and longitude

Latitude and longitude values are usually found comma seperated to denote a location on the globe

$ pattern/^((\-?|\+?)?\d+(\.\d+)?),\s*((\-?|\+?)?\d+(\.\d+)?)$/gm
locationaddress
16

mac address

A simple expression to match an ethernet MAC address

$ pattern/^[a-fA-F0-9]{2}(:[a-fA-F0-9]{2}){5}$/gm
address
17

url slug

A ‘slug' is the part that comes at the very end of a URL, and refers to a specific page or post. Usually a combination of word that separated with hyphen

$ pattern/^[a-z0-9]+(?:-[a-z0-9]+)*$/gm
slugurllink
18

C-like identifier

In computer languages, identifiers are tokens (also called symbols) which name language entities

$ pattern/^[a-zA-Z_][0-9a-zA-Z_]*$/gm
cidentifier
19

hyphen word break

A hyphen appears at the end of a line when the word must be split to fit on the line

$ pattern/[a-zA-Z][\-]$[\n][a-zA-Z]/gm
hyphenword_break
20

bitcoin address

A bitcoin address is the address string which identifies a bitcoin cryptocurrency wallet.

$ pattern/^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/gm
cryptoaddress
21

emoji

Emojis or emoticons are symbols used to denote various emotions in electronic messages.

$ pattern/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/gm
emojiemoticonsmiley
22

credit card number

Credit card number is the card unique identifier found on payment cards.

$ pattern/(^4[0-9]{12}(?:[0-9]{3})?$)|(^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$)|(3[47][0-9]{13})|(^3(?:0[0-5]|[68][0-9])[0-9]{11}$)|(^6(?:011|5[0-9]{2})[0-9]{12}$)|(^(?:2131|1800|35\d{3})\d{11}$)/gm
credit cardpayment cardVisa
23

pan from gstin

A PAN is a unique identifier issued to all judicial entities identifiable under the Indian Income Tax Act, 1961

$ pattern/^([0][1-9]|[1-2][0-9]|[3][0-5])([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1})([1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-Z]{1})+$/igm
PAN FROM GSTINGSTINGST
24

e.164 phone number

E.164 is a telephone number format to ensure consistency

$ pattern/^\+[1-9]\d{1,14}$/igm
phonee.164number
25

han unification

Han characters are a common feature of written Chinese (hanzi), Japanese (kanji), and Korean (hanja)

$ pattern/^[\u4E00-\u9FFF\u3400-\u4DBF\u20000-\u2A6DF\u2A700-\u2B73F\u2B740-\u2B81F\u2B820-\u2CEAF\u2CEB0-\u2EBEF\u30000-\u3134F\uF900-\uFAFF\u2E80-\u2EFF\u31C0-\u31EF\u3000-\u303F\u2FF0-\u2FFF\u3300-\u33FF\uFE30-\uFE4F\uF900-\uFAFF\u2F800-\u2FA1F\u3200-\u32FF\u1F200-\u1F2FF\u2F00-\u2FDF]+$/gm
hanschinesejapanese
26

port number

A port is a communication endpoint associated with a specific address

$ pattern/^((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4}))$/gm
portipnetwork
27

digital object identifier

A DOI is an identifier/handle used to identify objects uniquely

$ pattern/^(10\.\d{4,5}\/[\S]+[^;,.\s])$/gmi
doidocumentidentifier
28

discord username

Username identifier for the VOIP application Discord

$ pattern/^.{3,32}#[0-9]{4}$/gmi
discordgamingusername
29

hashtag

Hashtags are metadata tags used on social networks that categorizes the content of the post

$ pattern/^#[^ !@#$%^&*(),.?":{}|<>]*$/gmi
hashtagtwittersocial