Categories

Regex Tester

Test and debug regular expressions with live match highlighting, capture groups, and replace.

3 matches

Matches highlighted

Launch dates: 2026-01-15, 2026-06-30 and 2026-12-01.

3 matches

Match 1
at index 142026-01-15
Group 1 · @142026
Group 2 · @1901
Group 3 · @2215
Match 2
at index 262026-06-30
Group 1 · @262026
Group 2 · @3106
Group 3 · @3430
Match 3
at index 412026-12-01
Group 1 · @412026
Group 2 · @4612
Group 3 · @4901

Replace

Use $1, $2 or $<name> for captured groups, $& for the whole match, and $$ for a literal $.

Quick reference

.Any char except newline (add s to include)
\d \DDigit / non-digit
\w \WWord char / non-word char
\s \SWhitespace / non-whitespace
\b \BWord boundary / non-boundary
^ $Start / end (of line with m flag)
* + ?0+, 1+, 0-or-1 (greedy)
*? +? ??Lazy (non-greedy) versions
{n} {n,} {n,m}Exactly n, n or more, n to m
[abc] [^abc]Character set / negated set
[a-z]Character range
a|bAlternation: a or b
( )Capturing group
(?: )Non-capturing group
(?<name> )Named capturing group
\1 \k<name>Backreference in the pattern
(?= ) (?! )Lookahead / negative lookahead
(?<= ) (?<! )Lookbehind / negative lookbehind

Online Regex Tester and Debugger

This free regex tester lets you build, test, and debug regular expressions against your own sample text and see every match highlighted live as you type. It shows a numbered and named breakdown of each capture group, a running match count, and a find-and-replace preview, so you can confirm a pattern does exactly what you expect before pasting it into your code.

It runs entirely in your browser using the native JavaScript regular expression engine, so the patterns and text you test are never uploaded or stored anywhere. That makes it safe for log samples, customer data, or anything else you would rather not send to a server.

How to use Regex Tester

  1. Type or paste your regular expression into the pattern field — enter the body only, without the surrounding slashes.
  2. Toggle the flags you need: g (find all matches), i (ignore case), m (multiline), s (dot matches newlines), u (unicode), and y (sticky).
  3. Paste the text you want to search into the test string box; matches are highlighted instantly.
  4. Review the match list to inspect each match's position and the value of every numbered or named capture group.
  5. Optionally type a replacement to preview a find-and-replace, using $1, $2, or $<name> to reference captured groups.
  6. Load one of the common patterns to start from a working example, then copy the finished /pattern/flags with one click.

Regex flags explained

  • g (global) — find every match instead of stopping at the first. With g off, only the first match is highlighted and only the first is replaced, exactly as JavaScript behaves.
  • i (ignore case) — match letters regardless of upper or lower case.
  • m (multiline) — make the ^ and $ anchors match at the start and end of each line, not just the whole string.
  • s (dotall) — let the . metacharacter match newline characters too.
  • u (unicode) — enable full Unicode matching and \p{...} property escapes.
  • y (sticky) — match only starting at the current position, which is useful when writing tokenizers.

Reading capture groups

Every pair of unescaped parentheses creates a numbered capturing group, counted from 1 in the order the opening parentheses appear. Naming a group with (?<name>...) lets you refer to it by name as well as by number. For each match, this tool lists every group with its captured text and, where the browser supports it, the position where the group started; an optional group that did not participate in the match is shown as unmatched rather than empty.

Pattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Text:    2026-08-11
Group 1 (year): 2026
Group 2 (month): 08
Group 3 (day): 11
Named groups are listed alongside their group number.

Find and replace with backreferences

The replacement box previews the result of a substitution without changing the engine's behavior. Use $1, $2, and so on to insert the text captured by a numbered group, $<name> for a named group, $& for the whole match, and $$ for a literal dollar sign. Because JavaScript only replaces every occurrence when the g flag is set, the replace preview follows the same rule: turn g off to replace only the first match.

Pattern:     (\d{4})-(\d{2})-(\d{2})   (flags: g)
Replacement: $3/$2/$1
2026-01-15  ->  15/01/2026
Reorder captured groups to reformat dates.

Common pattern presets

The preset buttons load a working pattern together with matching sample text, so you can see it in action immediately and adapt it to your needs. Presets include email addresses, URLs, IPv4 addresses, ISO and named-group dates, 24-hour times, US phone numbers, hex colors, URL slugs, and hashtags. They are practical starting points rather than exhaustive validators — for example, no single pattern matches every technically valid email address.

Handling errors and edge cases

If a pattern is incomplete or invalid, the tool shows the JavaScript engine's error message instead of crashing, so you can fix it as you type. Patterns that can match an empty string, such as a* or a lookahead, are handled safely: the tool advances past each zero-length match so it never gets stuck in a loop, and it marks the position of an empty match in the highlighted text. Very large result sets are capped so the page stays responsive.

Related terminology

Regular expression
A pattern that describes a set of strings, used to search, match, split, and replace text. This tool uses the JavaScript (ECMAScript) flavor of regular expressions.
Capture group
A parenthesized part of a pattern whose matched text is remembered separately, so it can be inspected, reused in a backreference, or referenced in a replacement as $1, $2, and so on.
Named group
A capture group written as (?<name>...) that can be referenced by name — $<name> in a replacement, or \k<name> inside the pattern — in addition to its group number.
Flag
A modifier that changes how a pattern is applied, such as g for global matching, i for case-insensitive matching, or m for multiline anchors.
Backreference
A reference to text captured earlier in the same match — \1 inside the pattern, or $1 in a replacement string.
Anchor
A zero-width token such as ^, $, or \b that matches a position (start of line, end of line, or word boundary) rather than a character.
Lookahead and lookbehind
Zero-width assertions such as (?=...) and (?<=...) that require text to be followed or preceded by a sub-pattern without including it in the match.

Frequently asked questions

Which regular expression flavor does this tester use?
It uses the native JavaScript (ECMAScript) engine built into your browser, so results match how regular expressions behave in JavaScript and TypeScript. Syntax specific to other flavors, such as PCRE or Python — for example (?P<name>...) — is not supported and is reported as an error.
Why are only some matches highlighted?
Highlighting follows the global (g) flag. With g enabled, every match in the test string is highlighted; with g disabled, JavaScript stops at the first match, so only the first is shown. Turn on the g flag to see all matches.
How do I use capture groups in the replacement?
Reference a numbered group with $1, $2, and so on, or a named group with $<name>. Use $& to insert the entire match and $$ to output a literal dollar sign. The Replace box previews the result live as you edit the pattern, flags, or replacement.
Is my pattern or test text sent to a server?
No. Everything runs locally in your browser with the built-in JavaScript engine — nothing you type is uploaded, logged, or stored, which makes the tool safe for sensitive log data and sample text.
Can I test multiline text and match across lines?
Yes. Enable the m flag so ^ and $ match at the start and end of each line, and enable the s flag so the dot (.) also matches newline characters. Both can be combined with the other flags.

Related tools