To test a regex, type your pattern into Regex Pattern without the surrounding slashes, tick the flags you need, and paste sample text into Test Text. Matches are highlighted as you type, and each one is listed with its index and capture groups. Select Run to rerun it, or use Next match to step through results.
How to use the regex tester
- Enter a pattern. Type it in Regex Pattern, for example
\b\d{3}-\d{4}\b, without slashes. Or choose a Quick Preset such as Email addresses or Dates YYYY-MM-DD. - Add test text. Paste it into Test Text, or select Choose file under Test against a file to load a log, CSV, JSON or code file.
- Set flags and mode. Tick g, i, m, s, u, y or d. Match Mode can find all matches, only the first, or just test whether there's a match.
- Read the results. Matches highlight live. Change Primary View to Replace preview, Split preview or Raw match summary, and check Matches & Groups for each capture.
A JavaScript regex tester: what that means
Regex syntax varies between languages. This tester compiles your pattern with JavaScript's built-in RegExp, exactly as new RegExp(pattern, flags) would in your browser or Node.js, so what matches here matches in your JavaScript code. Errors appear under Errors & Parser Notes with the browser's own message.
Most everyday syntax is shared with Python, PHP (PCRE) and Java: character classes, quantifiers, groups, lookahead and backreferences. A few things differ. JavaScript has no \A or \Z anchors, so use ^ and $; it has no possessive quantifiers or atomic groups; and named groups use (?<name>...).
When you're done, Copy /pattern/flags copies a literal like /\d+/g. If your pattern contains a forward slash, escape it as \/ before pasting the literal into code.
Regex cheat sheet
| Token | Matches |
|---|---|
. | Any character except a line break (any character with the s flag) |
\d \w \s | A digit, a word character (letter, digit, underscore), whitespace |
\D \W \S | The opposite of each of the above |
\b | A word boundary |
^ $ | Start and end of the text (of each line with the m flag) |
[abc] [^abc] [a-z] | One of, none of, or a range of characters |
* + ? {2,5} | 0 or more, 1 or more, 0 or 1, between 2 and 5 |
*? +? | Lazy versions that match as little as possible |
(abc) (?:abc) | Capturing group, non-capturing group |
(?<year>\d{4}) | Named capturing group |
\1 | Backreference to group 1 |
a|b | a or b |
(?=x) (?!x) | Followed by x, not followed by x |
(?<=x) (?<!x) | Preceded by x, not preceded by x |
To match a special character such as ., ? or ( literally, put a backslash in front of it. Escape text does that for you: it takes the text in Test Text and turns it into a pattern that matches it exactly.
JavaScript regex flags explained
- g (global) finds every match instead of stopping at the first. Find all matches mode always searches globally.
- i (ignore case) makes
amatchA. - m (multiline) lets
^and$match at each line break. - s (dotAll) lets
.match line breaks too. - u (unicode) treats emoji and other characters outside the Basic Multilingual Plane as one character and enables
\p{...}property escapes such as\p{L}for any letter. - y (sticky) only matches starting exactly where the previous match ended.
- d (indices) makes
exec()results include start and end positions for each group. The tester accepts it, though its list shows each match's start index only.
Regex replace and split preview
The Replacement field uses the same syntax as JavaScript's String.replace(): $1 and $2 insert numbered groups, $<name> a named group, $& the whole match and $$ a literal dollar sign. For example, pattern (\d{4})-(\d{2})-(\d{2}) with replacement $3/$2/$1 turns 2026-10-11 into 11/10/2026. Without the g flag only the first match is replaced, just as in your code.
Split preview shows the parts produced by text.split(regex), numbered from 0. Capturing groups in the pattern are included in the split results: use (?:...) if you don't want them. To compare a replaced result with the original, paste both into the diff checker.
Why is my regex slow or not matching?
- Catastrophic backtracking. Nested quantifiers like
(a+)+$or(\w+\s?)*$can take exponential time on text that almost matches. This tester runs each match in a background worker and stops it after 2 seconds with a timed-out message, so the page stays usable, but in production the same pattern can stall a server (known as ReDoS). Avoid nesting quantifiers. - Greedy matching.
<.*>matches from the first<to the last>on the line. Use the lazy<.*?>or<[^>]*>. - Double escaping in strings. In
new RegExp("\\d+")the backslash must be doubled. In this tester, type the pattern as you would inside a/literal/. - The g flag and
test(). A global regex rememberslastIndex, so callingtest()twice on the same string can return true and then false.
For regex work on JSON, check the data's structure first in the JSON formatter.
Frequently asked questions
Which regex engine does this regex tester use?
It uses your browser's JavaScript RegExp engine, so results match what JavaScript code in that browser or in Node.js produces. Other languages such as Python and PHP may treat some syntax differently.
Do I include the slashes around the pattern?
No. Type only the pattern, such as \d+, and choose flags with the checkboxes. Copy /pattern/flags gives you the full literal for your code.
How do I see capture groups?
Every match in the Matches & Groups panel lists its groups as Group 1, Group 2 and so on. Named groups appear by their number. Raw match summary shows the same data as plain text.
Is there a limit on matches?
Find all matches stops at 10,000 matches and adds a note. Matching also stops if it takes longer than 2 seconds.
Is my test text uploaded?
No. The pattern, test text and any file you open stay in your browser. Matching runs locally.
What does the regular expression tester's Test only mode do?
It checks whether the pattern matches anywhere, like regex.test() in JavaScript, and shows just the first match. Use it for validation patterns where you only need a yes or no.