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,}$/user@example.comjohn.doe+test@sub.domain.orguser@.com@missing-user.comuser@exampleconst regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
regex.test('user@example.com');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()@:%_\+.~#?&\/=]*)$/https://www.example.comhttp://sub.example.co.uk/path?q=1www.example.comhttps://htp://example.comconst 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');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,}$/StrongP@ss1P4ssw0rd!weakpassOnlyUpper1NoSpecialChar1const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
regex.test('StrongP@ss1');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]?)$/192.168.1.1255.255.255.0256.1.1.1192.168.1192.168.1.1.1const 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');Hex Color Code
Matches 3 or 6 digit hex color codes.
/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/#FFF#000000#a3f#ZZZ#1234123456const regex = /^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/;
regex.test('#FFFFFF');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])$/2023-12-251999-01-012023-13-0123-01-012023/12/25const regex = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/;
regex.test('2023-12-25');Extract HTML Tags
Matches HTML tags and their attributes.
/<\/?([a-zA-Z0-9]+)(?:\s+[^>]+)?>/g<div class="test"></div><img>1 < 2Not a tagconst regex = /<\/?([a-zA-Z0-9]+)(?:\s+[^>]+)?>/g;
const str = '<div>test</div>';
const tags = str.match(regex);Trim Whitespace
Matches leading and trailing whitespace to trim it.
/^\s+|\s+$/g test \twordend\nno-whitespacemiddle whitespaceconst regex = /^\s+|\s+$/g;
' test '.replace(regex, '');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!