Regex Tester — JavaScript Regular Expression Tester Online
Test JavaScript regular expressions online: live match highlighting, capture and named groups, all flags and a replace preview. Slow patterns stop after 1s.
Convert in your browser · No sign-up
Cheat sheet
.- Any character except a line break (use the s flag to include them)
\d \w \s- Digit, word character [A-Za-z0-9_], whitespace
\D \W \S- Not a digit, not a word character, not whitespace
[abc] [^abc]- One of a, b, c / any character except a, b, c
[a-z]- Any character from a to z
^ $- Start / end of input (of each line with the m flag)
\b- Word boundary
* + ?- 0 or more, 1 or more, 0 or 1
{2,5}- Between 2 and 5 times ({3} exactly, {2,} at least)
*? +?- Lazy versions: match as few as possible
(abc)- Capturing group
(?<name>abc)- Named capturing group
(?:abc)- Group without capturing
\1 \k<name>- Repeat what group 1 / the named group matched
a|b- a or b
(?=a) (?!a)- Followed by a / not followed by a
(?<=a) (?<!a)- Preceded by a / not preceded by a
\p{L}- Any letter in any language (needs the u or v flag)
Uses your browser's JavaScript (ECMAScript) regex engine, so results match JavaScript code. Other engines such as PCRE, Python or Java differ in some syntax. Matching runs in a background worker and stops after 1 second to protect the page from catastrophic backtracking.
How to use
- Enter a regular expression and tick the flags you need (g finds all matches).
- Paste the text to test; matches are highlighted and listed with their index and capture groups.
- Turn on Replace to preview the result of String.replace with $1 or $<name> references.
Example
Pattern: (?<user>\w+)@(\w+)\.com flags: g Text: [email protected], [email protected] Matches: [email protected] (user = alice, 2 = example), [email protected] Replace with $<user> at $2 → alice at example, bob at test
Details and limitations
Patterns run with the JavaScript RegExp engine built into your browser, so lookbehind, named groups, Unicode property escapes and the d flag behave exactly as in your code. The v flag appears only if your browser supports it.
Matching happens in a Web Worker on your device; nothing is uploaded. A run is stopped after about 1 second, and at most 1,000 matches are listed.
FAQ
Why does my regex only find one match?
In JavaScript a regex without the g (global) flag stops at the first match. Tick g to find every match; this tester then lists them all.
What is catastrophic backtracking?
Some patterns, such as (a+)+$ or (.*)*, can take exponential time on text that almost matches. This tool runs the regex in a separate worker and stops it after 1 second, so the page stays responsive and shows an error instead.
Will a regex tested here work in Python or PHP?
Often, but not always. This tester uses JavaScript's engine. Python, PHP (PCRE) and Java have different features and syntax for things like named groups, lookbehind and flags, so re-check patterns that rely on them.
Related tools
Format references
Tool page updated: