Skip to regex tester
Done
Real-time · Capture groups · Replace preview

Regex Tester

Test and debug regular expressions with live match highlighting, a capture-group table, and a replace preview that understands $1 backreferences. Presets for email, URL, IP, UUID, and more. Uses the native JavaScript RegExp engine.

Last reviewed: August 24, 2026 Built by Khalil Rahman 100% browser-based
Presets:
Flags:
Matches will appear here as you type…
Tip: Wrap parts of your pattern in parentheses to create capture groups. The Match details table shows what each group captured — handy when debugging $1/$2 replacements.

How to use this Regex Tester

  1. Enter your pattern. Type or paste a regex into the Pattern field. The /.../ delimiters and active flags are shown around it so you can copy them straight into JavaScript.
  2. Toggle flags. Click g, i, m, s, u, or y depending on how the pattern should behave. Changes take effect instantly.
  3. Paste your test string. Matches highlight live. The stats row shows how many matches were found and how long the engine took.
  4. Check the Match details table. Each row shows the matched text, its capture groups, and the character index — useful when a replacement is producing unexpected output.
  5. Preview replacements. Enter a replacement string (using $1, $2 for capture groups and $& for the whole match) and click Replace All.

What is a regular expression?

A regular expression is a pattern that describes a set of strings. The engine walks the input and finds substrings that match the pattern. Regular expressions are used everywhere — validating form input, searching log files, extracting data from HTML, parsing config files, and splitting text into tokens.

Patterns are built from literals (like abc), character classes ([a-z], \d, \w), quantifiers (+, *, ?, {n,m}), groups ((...)), and anchors (^, $, \b). Combining these lets you describe almost any text format.

Regex cheat sheet

TokenMeaning
.Any character except newline (with s flag: any character)
^Start of string (or line with m flag)
$End of string (or line with m flag)
\d / \DDigit / not a digit
\w / \WWord character (A-Za-z0-9_) / not a word character
\s / \SWhitespace / not whitespace
\bWord boundary
[abc]Any of a, b, or c
[^abc]Any character except a, b, or c
a*Zero or more a's (greedy)
a+One or more a's
a?Zero or one a
a{n,m}Between n and m a's
a*?Zero or more a's (lazy — matches as few as possible)
(abc)Capture group — captured value is available as $1
(?:abc)Non-capturing group
(?<name>abc)Named capture group
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind
\1Backreference to capture group 1

Common mistakes when writing regex

  • Forgetting the g flag. Without g, only the first match is found. If your tool claims "1 match" and you can see three in the text, this is why.
  • Greedy vs lazy. .* is greedy — it consumes as much as possible. To match the shortest valid string, use .*?.
  • Catastrophic backtracking. Nested quantifiers like (a+)+ or (.*)* cause the engine to try exponentially many paths on non-matching input. This tool warns you when it detects the pattern.
  • Unescaped special characters. A literal dot must be written as \.. A literal ( must be written as \( — otherwise the engine interprets it as the start of a group.
  • Mixing up \b and \B. \b is a word boundary — it matches between a word character and a non-word character. \B is the opposite.
  • Ignoring multiline text. ^ and $ only match the start and end of the entire string by default. Add m to match line boundaries.
  • Unicode surprises. Without the u flag, emoji and astral characters are treated as two code units. Use u whenever your input may contain non-ASCII characters.

Why browser-based matters for regex testing

Regular expressions are often used on data that should never leave your device — API keys in config files, user records in log files, personally identifiable information in dumps. A server-based regex tester has to send that input to the server, which means it exists in their logs. This tool does everything in the browser using the native JavaScript RegExp engine. Nothing you type is uploaded.

That is also why the pattern here behaves exactly as it will in your JavaScript code — it uses the same engine, not a PCRE approximation or a translated dialect.

Khalil Rahman

Full-stack developer and founder of SkillsInsider. I built this tool because most regex testers hide capture groups or fail silently when a pattern is dangerous — and I have spent too many hours staring at a frozen browser tab because of one badly nested quantifier. Send a message if a pattern doesn't behave the way you expect.

Frequently asked questions

This tester uses the browser's native JavaScript RegExp engine (ECMAScript). It supports all standard features — character classes, quantifiers, capture groups, backreferences, lookahead and lookbehind, and the u (unicode) flag. JavaScript does not support PCRE-only features like atomic groups, possessive quantifiers, or recursion — if you paste a pattern using those, you will see a specific error message rather than a mysterious failure.

No. Everything runs in your browser. The pattern, test string, and matches never leave your device. The only network requests after page load are the Bootstrap Icons stylesheet and — if you accept the cookie banner — Google Analytics, which sees the page visit but never the text you enter.

  • g — global: find all matches, not just the first.
  • i — case-insensitive: ignore letter case.
  • m — multiline: ^ and $ match the start and end of each line instead of the whole string.
  • s — dotAll: . matches newline characters too.
  • u — unicode: enables full Unicode support including \p{...} property escapes.
  • y — sticky: matches only at the lastIndex position. Combined with g, it means "match here, then advance", which is useful for tokenizers but not for finding all matches.

That is called catastrophic backtracking — it happens when a pattern has nested quantifiers like (a+)+ or (.*)* and the input almost-but-not-quite matches. JavaScript has no built-in timeout for regex execution, so a pathological pattern can hang the tab. This tool shows a warning when it detects a nested-quantifier pattern so you can rewrite it before running. If a pattern does hang, close the tab and reopen it — the page state is reset.

Wrap parts of your pattern in parentheses to create capture groups, then reference them in the replacement as $1, $2, $3 (in order). For example, the pattern (\w+)@(\w+)\.com with replacement $2:$1 turns [email protected] into gmail:user. Use $& for the entire match, and $$ for a literal dollar sign.

The sticky flag anchors matching to the current lastIndex — it does not allow the engine to skip ahead to find a match. Combined with g, it means "match at this exact position, then advance". If you want all matches anywhere in the text, use g alone. Use gy only when you need to tokenize a string sequentially and want to know if there is any gap.

Yes, when the u flag is enabled. Without u, astral-plane characters (emoji, some CJK characters) are treated as two code units, which breaks patterns that use quantifiers or character classes on them. Enable u whenever your input may contain non-ASCII text — \p{Emoji} and similar property escapes only work with u enabled.

Yes. Click Share and the tool encodes the pattern, flags, test string, and replacement into the URL. Whoever opens the link sees the same setup. The URL is built client-side — nothing is uploaded — but be careful: if your test string contains secrets, they will appear in the URL, which is visible in browser history and any chat app you paste it into.

More developer tools