Regex Tester

Test your Regular Expressions

Write a regex, paste a test string, and see matches highlighted in real time

//g
Flags:
0 matches

Enter a pattern and test string to see results.

What is a Regular Expression?

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Originally developed in theoretical computer science and formal language theory, regular expressions are now used in virtually every programming language for string searching, matching, and manipulation.

In JavaScript, regular expressions are objects created with the RegExp constructor or as a literal between forward slashes: /pattern/flags. They are used with methods like .test(), .exec(), .match(), and .replace() to find, extract, or transform text.

Regex Syntax Reference

TokenDescriptionExample
.Any character except newline (unless s flag)a.b matches "acb"
\dAny digit (0-9)\d+ matches "123"
\wAny word character (a-z, A-Z, 0-9, _)\w+ matches "hello"
\sAny whitespace (space, tab, newline)a\sb matches "a b"
^Start of string (or line with m flag)^Hello matches start
$End of string (or line with m flag)world$ matches end
*Zero or more of the previous tokenab*c matches "ac", "abc"
+One or more of the previous tokenab+c matches "abc"
?Zero or one of the previous tokencolou?r matches both
{n,m}Between n and m of the previous tokena{2,4} matches "aa"
[abc]Character class — any one of a, b, or c[aeiou] matches vowels
[^abc]Negated class — anything except a, b, c[^0-9] matches non-digits
(abc)Capture group(\d+) captures digits
(?:abc)Non-capturing group(?:ab)+ groups without capture
a|bAlternation — match a or bcat|dog matches either
\bWord boundary\bword\b matches whole word

Common Regex Patterns

Use CasePattern
Email address[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
URL (http/https)https?:\/\/[\w\-._~:/?#\[\]@!$&'()*+,;=%]+
US phone number\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
IPv4 address\b(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.(?:...){3}\b
Date (YYYY-MM-DD)\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
Hex color code#(?:[0-9a-fA-F]{3}){1,2}\b
HTML tag<\/?[a-zA-Z][a-zA-Z0-9]*[^>]*>
Positive integer^[1-9]\d*$

Regex Flags Explained

FlagNameDescription
gGlobalFind all matches instead of stopping after the first one.
iCase-InsensitiveMatch uppercase and lowercase letters interchangeably.
mMultiline^ and $ match the start and end of each line, not just the whole string.
sDotAllThe . metacharacter matches newline characters as well.
uUnicodeTreat the pattern and input as Unicode. Enables correct handling of surrogate pairs.

Frequently Asked Questions

Yes, completely free with no limits. Test as many patterns as you want without creating an account.

Absolutely. Everything runs 100% in your browser using JavaScript. Your patterns and test strings never leave your device — nothing is sent to any server.

This tool uses the JavaScript RegExp engine built into your browser. It supports all standard JavaScript regex features including lookaheads, lookbehinds (in modern browsers), named groups, and Unicode property escapes with the u flag.

Common causes include unescaped special characters (like unmatched parentheses or brackets), invalid quantifiers, or using syntax not supported in JavaScript. Check the error message for specifics, and make sure to escape special characters with a backslash.

Flags modify how the regex engine behaves. 'g' finds all matches (not just the first), 'i' makes matching case-insensitive, 'm' makes ^ and $ match line boundaries, 's' makes the dot (.) match newlines, and 'u' enables full Unicode support.

Parentheses () create capture groups that extract portions of the matched text. For example, (\d{4})-(\d{2})-(\d{2}) on '2026-04-13' captures three groups: '2026', '04', and '13'. Groups appear in the match details panel.

Yes, JavaScript supports lookaheads (?=...) and (?!...) in all browsers. Lookbehinds (?<=...) and (?<!...) are supported in modern browsers (Chrome 62+, Firefox 78+, Safari 16.4+).

A regex with the 'g' flag that matches an empty string (e.g., /a*/) can loop forever because it keeps matching at the same position. This tool automatically advances the position when an empty match occurs, preventing infinite loops.