Regex Tester & Explainer

Test, debug, and understand regular expressions in real time with match highlighting

A regex tester lets you write and debug regular expressions against sample text in real time. Regular expressions (regex) are powerful pattern-matching sequences used in programming, data validation, and text processing. This free tool highlights matches instantly, shows captured groups, and supports find-and-replace with regex substitution.

Regular Expression

/ / g

Common Presets

Test String

0
Matches
0
Groups
0
String Length
0
Time (ms)

Replace Mode

Regex Quick Reference

Character Classes

.Any character (except newline)
\dDigit [0-9]
\DNot a digit
\wWord character [a-zA-Z0-9_]
\WNot a word character
\sWhitespace
\SNot whitespace
[abc]Character set (a, b, or c)
[^abc]Negated set (not a, b, or c)
[a-z]Range (a through z)

Quantifiers

*0 or more
+1 or more
?0 or 1
{n}Exactly n
{n,}n or more
{n,m}Between n and m
*?Lazy: 0 or more (fewest)
+?Lazy: 1 or more (fewest)

Anchors & Boundaries

^Start of string/line
$End of string/line
\bWord boundary
\BNot a word boundary

Groups & Lookaround

(abc)Capture group
(?:abc)Non-capture group
(?<name>abc)Named capture group
a|bAlternation (a or b)
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind

How to Use the Regex Tester

Regular expressions are one of the most powerful tools in a developer's toolkit, but writing and debugging them can be frustrating without instant feedback. This regex tester gives you real-time match highlighting, captured group details, and a built-in replace mode so you can iterate on patterns quickly and confidently.

Step 1: Enter Your Regex Pattern

Type your regular expression into the pattern field at the top. The tool uses JavaScript's RegExp engine, so all standard JavaScript regex syntax is supported. Select flags using the checkboxes below the input: enable g (global) to find all matches, i for case-insensitive matching, m for multiline mode, s to make the dot match newlines, and u for full Unicode support.

Step 2: Paste Your Test String

Enter the text you want to test against in the test string textarea. As you type, the tool instantly highlights all matches in the text and updates the match count and details. Alternating colors help you visually distinguish adjacent matches.

Step 3: Review Match Results

The match details panel shows every match with its index position, full matched text, and any captured groups. Named groups are displayed with their names. This is especially useful when debugging complex patterns with multiple capture groups or alternations.

Step 4: Use Replace Mode

Enter a replacement string to see a find-and-replace preview in real time. Use $1, $2, etc. to reference captured groups, or $& for the entire match. The result updates live, making it easy to compose complex substitution patterns before using them in your code.

Tips for Better Regex

Use the common presets to quickly test patterns for emails, URLs, phone numbers, dates, IP addresses, and hex colors. The collapsible cheatsheet covers character classes, quantifiers, anchors, groups, and lookaround assertions so you can reference syntax without leaving the page. All processing runs locally in your browser, so your test data is never sent anywhere.

Frequently Asked Questions

Is this regex tester completely free?

Yes, our regex tester is 100% free with no limits. You can test, debug, and experiment with as many regular expressions as you need. There is no account required, no usage caps, and no premium tier.

Is my data safe when using this regex tester?

Absolutely. Everything runs entirely in your browser using client-side JavaScript. Your test strings and regex patterns are never sent to any server, never stored, and never logged. It is completely safe to test patterns against sensitive data.

What regex flags are supported?

The tool supports all standard JavaScript regex flags: global (g) for finding all matches, case-insensitive (i) for ignoring letter case, multiline (m) for treating each line as a separate string, dotAll (s) for making the dot match newlines, and unicode (u) for full Unicode support including surrogate pairs.

How does the replace mode work?

Replace mode lets you enter a replacement string that uses standard regex substitution syntax. You can reference captured groups with $1, $2, etc., the entire match with $&, and use special tokens like $` and $' for text before and after the match. The replaced result updates in real time as you type.

What are the common regex presets available?

The tool includes ready-to-use presets for matching email addresses, URLs, phone numbers, dates in various formats, IPv4 addresses, and hex color codes. Click any preset to instantly load the pattern and a sample test string so you can see it in action.

Can I use this tool to learn regular expressions?

Yes, this tool is great for learning regex. The collapsible cheatsheet covers all major regex syntax including character classes, quantifiers, anchors, groups, and lookaheads. Combined with real-time match highlighting, you can experiment and see exactly what each part of your pattern matches.

Does the regex tester show captured groups?

Yes, the match results panel shows every match along with its captured groups, index position, and the full matched text. Named groups are also displayed with their group names, making it easy to debug complex patterns with multiple capture groups.