Regex Tester
Test a JavaScript regex as you type, inspect every match and capture, then return to the same local working state later.
- Fewer clicks, keyboard friendly
Flags
Highlighted matches
Regex can find words in English and 한글 text. Try 42 or hello@example.com.
Match details
- Match 1Index 0–5
Regex
Capture groups$1: RegexNamed groupsword: Regex - Match 2Index 6–9
can
Capture groups$1: canNamed groupsword: can - Match 3Index 10–14
find
Capture groups$1: findNamed groupsword: find - Match 4Index 15–20
words
Capture groups$1: wordsNamed groupsword: words - Match 5Index 21–23
in
Capture groups$1: inNamed groupsword: in - Match 6Index 24–31
English
Capture groups$1: EnglishNamed groupsword: English - Match 7Index 32–35
and
Capture groups$1: andNamed groupsword: and - Match 8Index 39–43
text
Capture groups$1: textNamed groupsword: text - Match 9Index 45–48
Try
Capture groups$1: TryNamed groupsword: Try - Match 10Index 52–54
or
Capture groups$1: orNamed groupsword: or - Match 11Index 55–60
hello
Capture groups$1: helloNamed groupsword: hello - Match 12Index 61–68
example
Capture groups$1: exampleNamed groupsword: example - Match 13Index 69–72
com
Capture groups$1: comNamed groupsword: com
Pattern explanation
(?<word>— group\b— escape[A-Za-z]— character class+— quantifier\b— escape
Ctrl/⌘ Shift L Focus pattern
How to use
- Type a JavaScript regular-expression pattern without surrounding / delimiters.
- Turn on the flags your code uses, such as g for every match or u for Unicode-aware matching.
- Paste test text and inspect the live highlights, UTF-16 indexes and capture groups.
- Optionally enter replacement text using $&, $1, or $<name> to preview JavaScript String.replace output.
- Read the compact token explanation, then copy the replacement result if it is what you expect.
This tester uses the JavaScript RegExp flavor
The pattern is passed to the browser’s built-in JavaScript RegExp constructor, so its syntax and flags follow ECMAScript rather than PCRE, Python, or .NET. That matters for constructs such as inline modifiers, possessive quantifiers, and engine-specific escapes, which may work elsewhere but are not JavaScript syntax. The six controls map to g (global), i (ignore case), m (multiline), s (dotAll), u (Unicode), and y (sticky).
The index beside each result is JavaScript’s UTF-16 code-unit index, the same kind of position exposed by RegExpExecArray.index. An emoji such as 😀 occupies two UTF-16 code units, so an index can be larger than the number of user-visible characters before it. This is expected when you are debugging browser or Node.js code.
Matches, capture groups, and replacement tokens
Parentheses create numbered capture groups: /(\d{4})-(\d{2})-(\d{2})/ captures year, month, and day as $1, $2, and $3. A named group such as /(?<year>\d{4})/ can be reused in replacement text as $<year>. $& inserts the entire match and $$ inserts a literal dollar sign. With g enabled, String.replace changes every match; without g, it replaces only the first match.
Use the highlight view to catch patterns that match too much, then compare the listed capture values with your intended extraction. The preview uses the same JavaScript replacement semantics as String.prototype.replace, so it is useful before putting a find-and-replace rule into application code.
Build regexes in small steps
Start with an exact literal, then add one character class, quantifier, anchor, or group at a time. For validation, anchors usually matter: ^\d+$ accepts a string made entirely of digits, while \d+ finds a digit sequence anywhere in the text. A greedy .* can consume farther than expected; .*? is its lazy form.
Regular expressions with nested, ambiguous repetition can take a very long time on certain input. Examples include (a+)+ and (\w+\s?)*. JavaScript cannot cancel a RegExp that is already running, so test a short sample first and make the input larger gradually. This interface limits rendered match details to 1,000 so a broad global pattern does not create an unmanageable result list.
Frequently asked questions
Which regex flavor does this tester use?
This tester uses the JavaScript (ECMAScript) RegExp engine built into your browser. Its g, i, m, s, u, and y flags and replacement output match JavaScript and modern browser behavior, not PCRE, Python re, Java, or .NET regular expressions.
Why is a match index different from the visible character count?
JavaScript reports regex indexes in UTF-16 code units. Most visible characters use one code unit, but an emoji such as 😀 uses two, so a match after one emoji can have an index that is one higher than a human character count. This is the index used by RegExpExecArray.index.
What does the g flag change?
The global g flag makes JavaScript continue after the first match, so this tester lists every match up to 1,000 and String.replace applies the replacement everywhere. Without g, JavaScript returns and replaces only the first match, even if later text also matches.
Can I use $1 or named groups in replacement text?
Yes. In JavaScript replacement text, $& inserts the full match, $1 through $99 insert numbered capture groups when they exist, $<name> inserts a named capture group, and $$ inserts one literal dollar sign. The preview applies those String.prototype.replace rules live.
Is the pattern or test text uploaded?
No. The regular expression, test text, flags, and replacement preview run in your browser. The current working state is saved only in this browser’s local storage so it can be restored after a refresh; it is not sent to a server.
Related tools
Updated 2026-10-15