Regex Tester

Test and debug regular expressions live with match highlighting.

/ /
Test String
Matches
Test string will be highlighted here

About the Regex Tester

Build and debug regular expressions against sample text with matches highlighted as you type. Capture groups are broken out individually, flags are toggled with a click, and replace mode previews the substitution result. The tool uses the browser native RegExp engine, so behaviour matches JavaScript exactly rather than approximating another dialect.

How to use the Regex Tester

  1. Enter your pattern and flags

    Type the expression and toggle flags such as g (global), i (case-insensitive), m (multiline) and s (dotall). Invalid patterns are reported with the engine error message.

  2. Paste the text to match against

    Every match is highlighted in place, with each capture group listed separately alongside its index and position in the string.

  3. Try a replacement

    Switch to replace mode and enter a substitution string using $1, $2 or named group references to preview the transformed output.

When to use it

Writing a validation pattern

Check an expression against both valid and deliberately malformed inputs before wiring it into form validation.

Extracting data from logs

Design capture groups that pull timestamps, status codes or identifiers out of a log line.

Debugging a pattern that fails

Narrow down which part of an expression is too greedy or too strict by editing it against real sample text.

Frequently asked questions

Which regex dialect does this use?

JavaScript (ECMAScript), because it runs on the browser native RegExp engine. Patterns that rely on PCRE or Python features such as lookbehind variations, atomic groups or possessive quantifiers may behave differently or fail to compile.

Why does my pattern only find the first match?

The global flag is off. Enable "g" to find every match rather than stopping at the first one.

How do I reference capture groups in a replacement?

Use $1, $2 and so on for numbered groups, or $<name> for named groups declared with (?<name>...). Use $& to insert the whole match.

Is my test data sent anywhere?

No. Both the pattern and the sample text are evaluated locally, so you can safely test against real log excerpts.

Why does my expression hang the page?

Nested quantifiers such as (a+)+ can trigger catastrophic backtracking, where the engine explores an exponential number of paths. Simplify the nesting or anchor the pattern more tightly.