Regex Tester & Debugger

Test JavaScript regular expressions online with match highlighting, capture groups, match positions and replacement preview.

All tools
developer Tool

Test and debug JavaScript regular expressions

developer Category Collection
JavaScript Regex Utility

Test, inspect and debug regular expressions

Your pattern and test text are processed in your browser. Nothing is sent to iToolsEra for regex matching.

Ready
0 characters
Enter the pattern without surrounding /slashes/. JavaScript RegExp syntax is used.
Flags
0 characters
Highlighted Matches No result yet

Run a regex to see highlighted matches.

Replacement Preview

Preview what JavaScript's replace operation would produce. Your original test text is never changed.

Preview Result

Enter replacement text and preview the result.

Maximum pattern length: 10,000 characters. Maximum test text: 200,000 characters. Long-running regex execution is isolated in a browser worker and stopped after a short safety timeout.

What Is a Regular Expression?

A regular expression, often called a regex, is a pattern used to search text for characters, words or structures that follow specific rules. Developers use regular expressions for tasks such as finding identifiers, extracting values, checking text formats, replacing repeated patterns and validating input.

A regex is made from ordinary characters and special syntax such as character classes, quantifiers, anchors and groups. The exact syntax depends on the regex engine, so a pattern that works in one programming language may need changes in another.

How to Use the Regex Tester

  1. Enter a JavaScript regular expression without surrounding slash delimiters.
  2. Select the flags you need, such as g for global matching or i for case-insensitive matching.
  3. Paste or type the text you want to test.
  4. Click Test Regex or press Ctrl/Cmd + Enter.
  5. Review the highlighted matches, match positions and capture groups.
  6. Use Replacement Preview when you want to see how JavaScript replacement text would change the result.

Regex Syntax Reference

SyntaxMeaningExample
.Any character except a newline by defaulta.c
\dDigit\d+
\wWord character\w+
\sWhitespace\s+
^Start of input or line depending on mode^Hello
$End of input or line depending on modeworld$
*Zero or more repetitionsa*
+One or more repetitionsa+
?Optional or lazy modifier depending on contexta?
{n}Exactly n repetitions\d{4}
[...]Character class[abc]
(...)Capturing group(abc)
(?:...)Non-capturing group(?:abc)
|Alternationcat|dog

JavaScript Regex Flags

FlagPurpose
gFind all matches instead of stopping after the first match.
iMatch letters without treating uppercase and lowercase as different.
mMake ^ and $ work with individual lines in multiline text.
sAllow the dot to match newline characters.
uEnable Unicode-aware regular-expression behavior.
yUse sticky matching from the regex current position.

Common Regex Examples

These examples are starting points rather than universal validators. Real-world formats can be more complicated than a short pattern suggests.

  • Numbers: \d+
  • ISO date: \b\d{4}-\d{2}-\d{2}\b
  • Whitespace: \s+
  • Hashtag: #[A-Za-z0-9_]+
  • Two captured words: ^(\w+)\s+(\w+)$

Understanding Capture Groups

Parentheses create capturing groups in JavaScript regular expressions. When a pattern such as (\d{4})-(\d{2})-(\d{2}) matches 2026-09-21, the full match is the complete date and the three groups contain the year, month and day. The tool displays these groups for each match so you can see exactly which parts of the pattern captured text.

Use (?:...) when you need grouping behavior but do not want a numbered capture group.

Debugging Common Regex Problems

No matches: check spelling, anchors, escaping, whitespace and case sensitivity. If the pattern should find more than one occurrence, check whether the g flag is required.

Only one match: JavaScript returns the first match when global matching is not enabled. Add the g flag when you want all matches.

Dot does not match a newline: JavaScript does not make . match line breaks by default. Try the s flag when that behavior is required.

Pattern works elsewhere but not here: regex engines differ. This tool uses JavaScript RegExp syntax and is not a PHP/PCRE, Python or .NET regex interpreter.

Regex Replacement Preview

The replacement preview uses JavaScript string replacement behavior. Replacement strings can reference capture groups with tokens such as $1 and $2. Without the g flag, a normal replacement replaces only the first match; with g, matching occurrences are replaced throughout the test string.

The preview is non-destructive: the original test text in the editor is not changed.

JavaScript Regex vs Other Regex Engines

Regular-expression features vary between languages and engines. This tool uses the browser's JavaScript RegExp implementation. A pattern copied from a PHP application, PCRE-based utility, Python program or .NET project may require changes before it behaves the same way in JavaScript.

When debugging a pattern for a specific application, test it in the same regex flavor used by that application before relying on the result.

Regex Performance and Safety

Some regular expressions can perform a very large amount of backtracking on certain inputs. This tool runs regex execution inside a browser Web Worker and stops an execution that exceeds its short safety timeout. Large test inputs are also limited for browser responsiveness.

If a pattern times out, simplify nested quantifiers, reduce ambiguous alternatives, or test a smaller sample before using the pattern in an application.

Are My Regex and Test Data Uploaded?

Regex compilation, matching and replacement preview are performed in your browser. The tool does not send the regex pattern or test string to iToolsEra for matching. Even with browser-side processing, avoid pasting secrets, passwords, private keys or other sensitive information into online tools unless your organization's security requirements allow it.

Frequently Asked Questions

A regex tester lets you enter a regular expression and sample text so you can see whether the pattern matches and inspect the resulting matches. This version also shows capture groups, positions and replacement previews for JavaScript regular expressions.
This tool uses the JavaScript RegExp engine provided by the browser. It is not a general PCRE, Python or .NET regex interpreter.
Check the literal characters, escaping, anchors, whitespace and case sensitivity. Also check whether the pattern expects a flag such as i or m. The test result can show that a regex is valid even when it has zero matches.
JavaScript returns the first match when global matching is not enabled. Select the g flag when you want the pattern to search for all matches.
Text inside parentheses creates a numbered capture group. For example, (\d{4})-(\d{2})-(\d{2}) creates three groups for the year, month and day. The tool lists the captured value for each match.
Yes. Paste multiline text into the test area. Use the m flag when you need ^ and $ to work relative to individual lines, and use the s flag when you want a dot to match newline characters.
Yes. Enter replacement text and click Preview Replacement. JavaScript replacement syntax, including capture references such as $1 and $2, is used. The original test string is not modified.
No. Version 1.0.0 intentionally uses the browser's JavaScript RegExp engine. Patterns written for PHP/PCRE, Python or another regex engine may require syntax changes.
No regex matching or replacement request is sent to iToolsEra. Processing takes place in the browser. You should still avoid entering sensitive information into any online tool unless permitted by your security policy.
Some patterns can cause heavy backtracking on particular inputs. Version 1.0.0 isolates execution in a browser worker and stops a long-running test. Simplifying nested quantifiers and ambiguous alternatives can improve performance.