Regex Tester
Build and debug regular expressions with live match highlighting, capture group inspection and a replace preview — free and instant. Your pattern and text stay in your browser.
Replace preview
Quick syntax reference
| Pattern | Meaning |
|---|---|
| . | Any character except newline (add the s flag to include newlines) |
| \d \w \s | Digit / word character / whitespace — capitals (\D \W \S) negate |
| [abc] [^abc] | Any listed character / any character not listed |
| ^ $ | Start / end of string (of each line with the m flag) |
| * + ? {2,5} | Quantifiers: 0 or more, 1 or more, optional, range — append ? to make lazy |
| (x) (?:x) (?<name>x) | Capturing / non-capturing / named capturing group |
| a|b | Match a or b |
| \b | Word boundary |
| (?=x) (?!x) (?<=x) (?<!x) | Lookahead / negative lookahead / lookbehind / negative lookbehind |
How to use the Regex Tester
- Type your pattern. Enter a regular expression without the surrounding slashes and tick the flags you need — g for all matches, i for case-insensitive, m, s, u and y for advanced behavior.
- Paste your test text. Every match is highlighted instantly as you type, in alternating colors so adjacent matches stay distinguishable.
- Inspect and reuse. Check the match table for positions and capture groups (numbered and named), try a replacement string in the replace preview, then copy the matches or the replaced text.
About this tool
This free online regex tester runs your pattern with the JavaScript (ECMAScript) regular expression engine — the exact same engine used by browsers and Node.js — so what works here works in your code. It highlights every match live, lists match positions, shows the contents of numbered and named capture groups, and includes a replace preview that understands $1, $& and $<name> substitution patterns. A built-in syntax reference covers character classes, quantifiers, groups, anchors and lookarounds, making it a handy companion whether you are writing form validation, extracting data from logs, or crafting a search-and-replace for your editor.
Your pattern and test text are processed entirely inside your browser — nothing is sent to a server, stored or logged. That makes it safe to debug expressions against production log excerpts, customer data or other confidential text, and the tester keeps working even without an internet connection once the page is loaded.
Frequently asked questions
Which regex flavor does this tester use?
JavaScript (ECMAScript), as implemented by your own browser. Most common syntax is shared with PCRE, and modern browsers also support lookbehind and Unicode property escapes like \p{Letter} (with the u flag). Features that JavaScript lacks — atomic groups, possessive quantifiers and recursion — will raise an "invalid regular expression" error.
Why does my pattern only find the first match?
Without the g (global) flag, a JavaScript regex stops after the first match. Tick the g checkbox to find every occurrence — the tester shows a reminder when g is off. The replace preview behaves the same way: with g it replaces all matches, without it only the first.
How do I use capture groups?
Wrap part of the pattern in parentheses: (\d{4})-(\d{2}) creates groups $1 and $2, and (?<year>\d{4}) creates a named group. The match table shows what each group captured for every match, and you can reference them in the replace preview as $1, $2 or $<year>.
Why does the page freeze with some patterns?
Patterns with nested quantifiers such as (a+)+b can trigger catastrophic backtracking, where the engine tries an exponential number of paths on non-matching text. Since matching runs in your browser, a pathological pattern can briefly hang the tab. Prefer more specific character classes and avoid stacking quantifiers on overlapping groups.