Regex Tester
Test JavaScript regular expressions live with match highlighting, capture groups, replace preview and a cheat sheet.
Match highlighting
Matches
| # | Match | Position | Groups |
|---|
Common patterns
100% private: everything runs in your browser and nothing is uploaded.
Regex cheat sheet
.- Any character except a line break
\d- A digit (0–9)
\w- A word character (letter, digit or underscore)
\s- A whitespace character
[abc]- Any one of a, b or c
[^abc]- Any character except a, b or c
[a-z]- Any character in the range a to z
^- Start of the string (or line with the m flag)
$- End of the string (or line with the m flag)
\b- Word boundary
*- Zero or more of the previous token
+- One or more of the previous token
?- Zero or one of the previous token
{n,m}- Between n and m repetitions
*?- Lazy (as few as possible) repetition
(abc)- Capturing group
(?:abc)- Non-capturing group
(?<name>abc)- Named capturing group
\1- Backreference to group 1
a|b- Matches a or b
(?=abc)- Followed by abc (lookahead)
(?!abc)- Not followed by abc
(?<=abc)- Preceded by abc (lookbehind)
(?<!abc)- Not preceded by abc
How to Test a Regular Expression
No sign-up, no installation — it works right here in your browser.
- Step 1:Type your pattern between the slashes and toggle the flags you need, or start from one of the common patterns.
- Step 2:Paste the text to test. Matches are highlighted instantly and listed with their positions and capture groups.
- Step 3:Optionally enter a replacement using $1 or $<name> to preview the result of String.replace, then copy it.
Regex Tester FAQ
Which regex flavour does this tester use?
It uses the JavaScript (ECMAScript) engine built into your browser, the same one used by Node.js, Deno and front-end code. Most syntax is shared with PCRE, Python and Java, but features such as possessive quantifiers or atomic groups are not available.
What do the g, i, m, s, u and y flags do?
g finds all matches instead of the first, i ignores case, m makes ^ and $ match at line breaks, s lets the dot match newlines, u enables full Unicode support and y (sticky) only matches at the current position.
How do I use capture groups in the replacement?
Refer to numbered groups with $1, $2 and so on, to named groups with $<name>, to the whole match with $& and to a literal dollar sign with $$.
Why is my regex very slow or timing out?
Nested quantifiers such as (a+)+ or (.*)* can cause catastrophic backtracking, where the engine tries an exponential number of combinations. Make quantifiers more specific, use character classes instead of the dot or anchor the pattern.
Is my test data private?
Yes. Patterns and test strings are evaluated locally in a browser worker and are never sent to a server.
Test and Debug Regular Expressions Online
Regular expressions are a compact language for finding, validating and transforming text: checking email addresses and phone numbers, extracting IDs from logs, rewriting URLs, parsing CSV lines or cleaning user input. They are also notoriously easy to get wrong, because a single misplaced quantifier or missing escape can match far more — or far less — than you intended. This free regex tester shows every match as you type, highlights it in the test text, lists the position and the content of each numbered and named capture group, and previews the result of a replacement using $1, $2 or $<name> references.
The tester uses the JavaScript (ECMAScript) regex engine of your browser, so the results match exactly what Node.js, TypeScript, React or browser code will do, including support for the g, i, m, s, u and y flags, named groups, lookbehind and Unicode. Patterns run in a background worker with a time limit, so even a pattern with catastrophic backtracking cannot freeze the page. Ready-made patterns for emails, URLs, IPv4 addresses, ISO dates, hex colours and numbers give you a head start, and the built-in cheat sheet explains the most important tokens. Nothing you type is uploaded — everything runs locally.