Regex Tester Online — Live Matches, Groups, and Replace (Free)
A free online regex tester for JavaScript-flavor regular expressions. Type a pattern, toggle flags (g, i, m, s, u, y), paste your test string, and see live highlighted matches, named and numbered capture groups, and exact match positions. Switch to Replace mode to preview substitutions with `$1`, `$&`, and `$<name>` backrefs. Everything runs in your browser — your patterns and test data never leave your machine.
Features
Live match highlighting
Every match is highlighted inline as you type. Empty matches and zero-width assertions are handled.
Capture groups, including named groups
See each capture group per match — numbered and `(?<name>...)` named groups are listed side by side.
All standard JavaScript flags
Toggle g (global), i (ignore case), m (multiline), s (dotAll), u (Unicode), y (sticky) with hover tooltips.
Replace mode
Preview substitutions in real time using `$1`, `$&`, `$<name>`, and `$$` patterns.
Built-in cheatsheet
A regex quick reference is one click away — anchors, character classes, quantifiers, groups, lookarounds.
Hang-proof — Web Worker with 1 s timeout
Regex execution runs in a dedicated Web Worker. If a pathological pattern triggers catastrophic backtracking, the worker is terminated after 1 second and a clear error is shown — your tab never freezes.
How to test a regex online
Pattern, flags, test string — instant feedback.
- Type your patternDrop your regex into the pattern field. Errors (unbalanced groups, invalid escapes) are shown immediately.
- Toggle the flags you needClick g for global, i for case-insensitive, m for multiline, and so on.
- Paste the test stringMatches are highlighted live in the text area. The right panel lists each match with its groups.
- Switch to Replace to preview substitutionsType a replacement string — use `$1`, `$&`, `$<name>` to reference capture groups.
Examples
Find email addresses
Pattern: \b\w+@\w+\.\w+\b Flags: g Text: Contact us at [email protected] or [email protected].
Matches: 2 #1 → [email protected] (at 14) #2 → [email protected] (at 38)
Mask digits in IDs
Pattern: \d Flags: g Replace: * Text: Order #1042 ships Mar 7
Order #**** ships Mar *
Named capture groups
Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Text: 2026-05-24Match: 2026-05-24 year: 2026 month: 05 day: 24
Frequently Asked Questions
- Which regex dialect does this tool use?
- JavaScript regex (ECMAScript). It is the dialect that runs inside browsers, Node.js, Deno, and Bun. PCRE-only features such as recursive patterns or `\Q...\E` escapes are not supported.
- Is my regex or test string sent to a server?
- No. All matching happens in your browser via the native `RegExp` engine. There is no backend round-trip; open DevTools and you will see zero network requests when you edit the pattern.
- Are named capture groups supported?
- Yes. Use the syntax `(?<name>...)` and the group will be listed by name in each match. In Replace mode you can reference it with `$<name>`.
- What happens with zero-length matches in global mode?
- The tester advances past zero-length matches so it does not get stuck in an infinite loop. Each empty match is still reported, marked at its position.
- Can I match across multiple lines?
- Yes. Use the `m` flag to make `^` and `$` match line boundaries, and the `s` flag to let `.` match newline characters as well.
- Why does my pattern fail with `(?<=...)`?
- Lookbehind assertions are supported in modern browsers (Chrome, Firefox, Safari 16.4+). Patterns are validated by the browser's engine — if you see an error, try a recent browser.
- What happens if I write a regex that causes catastrophic backtracking?
- JavaScript's native regex engine cannot be interrupted from JS code in the same thread, so a pathological pattern like `(a+)+b` against a long string of "a"s without a trailing "b" would normally freeze the browser tab. This tool runs every regex inside a dedicated Web Worker; if the worker has not returned a result after 1 second, it is terminated and an error is shown ("Pattern timed out — simplify the regex"). Your tab stays responsive throughout.