Regex Tester & Debugger

Build and test regular expressions live, with match highlighting, capture groups, and a replace preview. Everything runs in your browser using the native JavaScript engine — nothing is uploaded.

Preset patterns

Flags

Enter a pattern above to start testing.
Highlighted matches

Matches

Replace preview

Result

        
0Matches
0Groups / match
0Pattern length
0Test-text length

How to Test a Regular Expression

  1. Type your expression in the Pattern box — no surrounding slashes, just the expression itself. Or click a preset chip to load a ready-made pattern.
  2. Tick the flags you need: g for every match, i for case-insensitive, m for multiline anchors, and so on.
  3. Paste or type your text into Test text. Every match is highlighted instantly and listed below with its capture groups.
  4. Add a replacement using $1, $2 or $<name> backreferences to preview a find-and-replace without altering your original text.

What Do the Regex Flags Mean?

Flags change how the whole pattern behaves. You can combine as many as you like:

  • g global — find every match instead of stopping at the first. Essential for replace-all.
  • i ignore case — treats A and a as the same character.
  • m multiline — makes ^ and $ match the start and end of each line, not just the whole string.
  • s dotall — lets . match newline characters too.
  • u unicode — enables full Unicode handling, including \p{...} property escapes and astral code points.
  • y sticky — anchors each match to the exact position where the last one ended.

Understanding Capture Groups

Parentheses create a capturing group that remembers the text it matched. They are numbered from left to right by their opening bracket, so in (\w+)@(\w+) the username is group 1 and the domain is group 2. This tool lists every group for each match so you can see exactly what was captured.

  • Named groups — write (?<year>\d{4}) to reference a group by name instead of a number.
  • Non-capturing groups — use (?:...) to group parts of a pattern without creating a numbered capture, which keeps your group numbers tidy.
  • Backreferences — in the replacement field, $1 inserts group 1, and $<year> inserts a named group. Use $$ for a literal dollar sign.

Writing Safe, Efficient Patterns

A few habits keep your regex fast and predictable. Anchor patterns with ^ and $ when you mean the whole string, prefer specific character classes like [a-z0-9] over a broad .*, and remember to escape special characters (. * + ? ( ) [ ] { } \ | ^ $) with a backslash when you want them treated literally.

Watch out for catastrophic backtracking — nested quantifiers such as (a+)+ can make an engine explore an explosive number of paths on non-matching input. Rewriting them with atomic, possessive-style character classes or clearer anchors keeps matching linear. This tester builds a fresh expression on every keystroke and guards its match loop against zero-length matches, so a stray global flag can never hang the page.

Frequently Asked Questions

Is my text sent anywhere?

No. The pattern, your test text and the replace preview are all processed locally in your browser with JavaScript. Nothing is uploaded, so it is safe for private logs, tokens and personal data.

Which regex engine does this use?

It uses your browser’s built-in JavaScript (ECMAScript) RegExp engine, so the results match exactly what your Node.js or front-end code will do. Syntax from other flavours such as PCRE or Python may behave slightly differently.

Why does my pattern only match once?

Because the global g flag is switched off. Without it, the engine stops at the first match and a replace only changes the first occurrence. Tick the g flag to match and replace every occurrence.

How do I use capture groups in the replacement?

Reference numbered groups with $1, $2 and so on, or named groups with $<name>. To output a literal dollar sign, write $$. The preview updates live as you type.

Related Tools

JSON Formatter · Text Case Converter · Base64 Encoder

All tools