Skip to content
ToolMug

Regex Tester

Write a regular expression, see every match highlighted as you type, inspect capture groups and try out replacements. It uses the JavaScript regex engine, and a pattern that takes too long is stopped instead of freezing the page.

Runs in your browser — nothing you enter is uploaded

//g
Common patterns:
 
Contact: ada@example.com, grace.hopper@navy.mil
Servers: 10.0.0.1, 192.168.1.255
Date: 2026-09-26

How to use

  1. Type the pattern between the slashes, or start from one of the common patterns.
  2. Toggle flags — g, i, m, s, u, y — to change how matching works.
  3. Paste your test text. Matches are highlighted and listed with their position and groups.
  4. Enter a replacement such as $1 or $<name> to preview the result of a search-and-replace.

Options explained

g (global)
Find every match rather than stopping at the first. The match list always shows all matches; g affects the replacement.
i (ignore case)
Letters match regardless of case.
m (multiline)
^ and $ match at the start and end of each line instead of the whole text.
s (dotAll)
. also matches line breaks.
u (unicode)
Treats the pattern as Unicode code points, enabling \p{…} property escapes and correct handling of emoji.
y (sticky)
Matches only at the exact position where the previous match ended.

Quick reference

Syntax Matches
\d \w \s Digit, word character, whitespace
[abc] [^abc] [a-z] One of, none of, range
* + ? {2,5} 0+, 1+, 0 or 1, between 2 and 5
*? +? Lazy — as few as possible
^ $ \b Start, end, word boundary
(…) (?:…) (?<name>…) Capture, non-capturing, named group
(?=…) (?!…) (?<=…) (?<!…) Lookahead, negative lookahead, lookbehind, negative lookbehind
\p{L} \p{Script=Han} Any letter, Chinese characters (with u flag)

Example

Pattern (?<user>[\w.+-]+)@(?<domain>[\w-]+(?:\.[\w-]+)+) on ada@example.com gives user = ada and domain = example.com; the replacement $<domain>/$<user> produces example.com/ada.

Frequently asked questions

Which regex flavour does this use?

JavaScript (ECMAScript 2024), as implemented by your browser. Most syntax is shared with PCRE, Python and Java, but lookbehind, named groups and Unicode escapes differ slightly between engines, so test in the language you will use.

Why did it say the pattern was stopped?

Some patterns, such as (a+)+$ on a long string of a's, make the engine try an exponential number of combinations — known as catastrophic backtracking. The tester runs in a background thread and stops after 1.5 seconds. Rewrite nested quantifiers or use more specific character classes.

How do I use capture groups in the replacement?

Use $1, $2… for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign.

Is my text sent anywhere?

No. Matching runs in a Web Worker in your browser, so logs and data you test against stay on your device.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools