RegexRef

Complete Pattern Library

📧

Email Address

Validates a standard email address format.

/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
✓ Matchesuser@example.comjohn.doe+test@sub.domain.org
✗ Non-matchesuser@.com@missing-user.comuser@example
javascript
const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
regex.test('user@example.com');
📖 View Guide
🔗

URL Validation

Validates a web URL including http/https protocols.

/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/
✓ Matcheshttps://www.example.comhttp://sub.example.co.uk/path?q=1
✗ Non-matcheswww.example.comhttps://htp://example.com
javascript
const regex = /^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/;
regex.test('https://example.com');
📖 View Guide
🔑

Strong Password

Requires at least 8 characters, one uppercase, one lowercase, one number, and one special character.

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/
✓ MatchesStrongP@ss1P4ssw0rd!
✗ Non-matchesweakpassOnlyUpper1NoSpecialChar1
javascript
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
regex.test('StrongP@ss1');
📖 View Guide
🖥️

IPv4 Address

Matches a valid IPv4 address (0-255 blocks).

/^(?:(?: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]?)$/
✓ Matches192.168.1.1255.255.255.0
✗ Non-matches256.1.1.1192.168.1192.168.1.1.1
javascript
const regex = /^(?:(?: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]?)$/;
regex.test('192.168.1.1');
📖 View Guide
🎨

Hex Color Code

Matches 3 or 6 digit hex color codes.

/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
✓ Matches#FFF#000000#a3f
✗ Non-matches#ZZZ#1234123456
javascript
const regex = /^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/;
regex.test('#FFFFFF');
📖 View Guide
📅

ISO Date (YYYY-MM-DD)

Matches dates in YYYY-MM-DD format (basic validation).

/^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/
✓ Matches2023-12-251999-01-01
✗ Non-matches2023-13-0123-01-012023/12/25
javascript
const regex = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/;
regex.test('2023-12-25');
📖 View Guide
🏷️

Extract HTML Tags

Matches HTML tags and their attributes.

/<\/?([a-zA-Z0-9]+)(?:\s+[^>]+)?>/g
✓ Matches<div class="test"></div><img>
✗ Non-matches1 < 2Not a tag
javascript
const regex = /<\/?([a-zA-Z0-9]+)(?:\s+[^>]+)?>/g;
const str = '<div>test</div>';
const tags = str.match(regex);
📖 View Guide
✂️

Trim Whitespace

Matches leading and trailing whitespace to trim it.

/^\s+|\s+$/g
✓ Matches test \twordend\n
✗ Non-matchesno-whitespacemiddle whitespace
javascript
const regex = /^\s+|\s+$/g;
'  test  '.replace(regex, '');
📖 View Guide