RegexRef Logo

Complete Pattern Library

Browse our collection of tested and proven regular expressions for common tasks.

Explore Ready-to-Use Regex Patterns

Discover carefully tested regular expressions for developers. Simply click any pattern to copy it or open it in our interactive regex tester.

📧

Email Address

Validates a standard email address format.

/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
Matches
user@example.comjohn.doe+test@sub.domain.org
Non-matches
user@.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()@:%_\+.~#?&\/=]*)$/
Matches
https://www.example.comhttp://sub.example.co.uk/path?q=1
Non-matches
www.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,}$/
Matches
StrongP@ss1P4ssw0rd!
Non-matches
weakpassOnlyUpper1NoSpecialChar1
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]?)$/
Matches
192.168.1.1255.255.255.0
Non-matches
256.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])$/
Matches
2023-12-251999-01-01
Non-matches
2023-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-matches
1 < 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-matches
no-whitespacemiddle whitespace
javascript
const regex = /^\s+|\s+$/g;
'  test  '.replace(regex, '');
📖 View Guide

How to Use Our Regex Pattern Library

Our regex pattern library is designed to save you time. Whether you need to validate complex data formats, parse URLs, or sanitize user input, these pre-built regular expressions are compatible with JavaScript, Python, Go, Rust, and more. Use our live playground to tweak any snippet before adding it to your codebase!