Regex Pattern Library
Collection of common, tested regular expression patterns for validation and matching.
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Example: user@example.com
\S+@\S+\.\S+Example: test@domain.org
https?://(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)Example: https://www.example.com/path
^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$Example: example.com
^(\+1[-\s]?)?\(?([0-9]{3})\)?[-\s]?([0-9]{3})[-\s]?([0-9]{4})$Example: (555) 123-4567
^\+[1-9]\d{1,14}$Example: +1234567890
^-?\d+$Example: -123, 456
^-?\d*\.?\d+$Example: 3.14159, -0.5
^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$Example: $1,234.56
^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/(19|20)\d\d$Example: 12/25/2023
^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$Example: 2023-12-25
^([01]?[0-9]|2[0-3]):[0-5][0-9]$Example: 14:30
^(?:(?: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]?)$Example: 192.168.1.1
^(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-fA-F\d]{1,4}|:)|...)$Example: 2001:0db8:85a3::8a2e:0370:7334
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|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})$Example: 4532015112830366
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$Example: MyP@ssw0rd
^[a-zA-Z0-9_-]{3,16}$Example: john_doe123
^[a-z0-9]+(?:-[a-z0-9]+)*$Example: my-blog-post
^#(?:[0-9a-fA-F]{3}){1,2}$Example: #FF5733, #FFF
^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$Example: rgb(255, 87, 51)
^[^\<>":/\\|?*\x00-\x1f]+\.[a-zA-Z0-9]{1,6}$Example: document.pdf
^(?:[a-zA-Z]:)?\\?(?:[^\\<>":|?*\x00-\x1f]+\\?)*[^\\<>":|?*\x00-\x1f]+$Example: /home/user/file.txt
^@?[a-zA-Z0-9_]{1,15}$Example: @username
^#?[a-zA-Z0-9_]+$Example: #javascript
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$Example: 550e8400-e29b-41d4-a716-446655440000
<\/?[\w\s="'&:;#]+\/?>Example: <div class='test'>
\.[a-zA-Z_-][a-zA-Z0-9_-]*Example: .my-class
Click the copy button on any pattern to copy it to your clipboard. These patterns can be used in:
JavaScript
const regex = /pattern/;
regex.test(string);Python
import re
re.match(r'pattern', string)