Regex Tester

Write a regular expression and see every match highlighted as you type. Inspect capture groups, preview replacements, and insert proven patterns from the library.

  • Live highlighting
  • Capture groups
  • Pattern library
/ / g
Test text No matches
Replace

    
Matches
No matches yet.
Pattern library
Use in code
How to use

How to use Regex Tester

  1. 01

    Write a pattern

    Type a regular expression and toggle flags such as global (g), case-insensitive (i), and multiline (m).

  2. 02

    Add test text

    Paste the text to search. Matches are highlighted live, and each one is listed with its capture groups.

  3. 03

    Replace and export

    Preview replacements using $1 or $, then copy the pattern as JavaScript or Python code.

Guide

About Regex Tester

Regex Tester helps you write, debug and understand regular expressions. Every match is highlighted as you type, capture groups are listed one by one, and you can preview replacements before using the pattern in your code.

How it works

Your pattern is compiled with the browser's native JavaScript regex engine, so what you see here is exactly what runs in Node.js, Deno and every modern browser. Modern features are supported, including named groups ((?<year>\d{4})), lookbehind ((?<=\$)\d+) and Unicode property escapes such as \p{L} with the u flag.

Matching runs in a background worker with a time limit. A pattern with catastrophic backtracking, like (a+)+$ on a long string, can't freeze the page. You'll get a timeout warning instead, which is also a useful hint that the pattern could hang in production.

Quick reference

  • \d digit, \w word character, \s whitespace, . any character
  • * zero or more, + one or more, ? optional, {2,5} between 2 and 5
  • ^ start and $ end of the text (or of each line with the m flag)
  • ( ) capture group, (?: ) non-capturing group, a|b either a or b
  • [abc] one of these characters, [^abc] none of these

Tips for better patterns

  • Start from the pattern library (emails, URLs, dates, phone numbers) and adapt it rather than writing from scratch.
  • Add the g flag to see every match, not just the first.
  • Use anchors (^…$) when validating a whole input, so "abc123xyz" doesn't pass as a number.
  • Prefer specific classes like [^"]* over .*. They're faster and less likely to over-match.
  • Name your groups. $<year> is far easier to read than $3 six months later.

At a glance

Flavor
JavaScript (ECMAScript)
Flags
g, i, m, s, u
Shows
Matches, groups, named groups
Replace
$1, $<name>, $& preview
Export
JavaScript or Python code
Safety
Runs in a worker with a time limit
Use Regex Tester Read the guideRegex Cheat Sheet: Regular Expressions Explained With Examples
FAQ

Questions about this tool

Something missing? Write to contact@ultratoolsai.com.

Which regex flavor is used?

JavaScript (ECMAScript) regular expressions, including named groups, lookbehind, and Unicode property escapes with the u flag.

What happens with a slow pattern?

Matching runs in a background worker with a time limit, so a catastrophic pattern can't freeze the page. You'll see a timeout warning instead.

How do I use capture groups in replacements?

Use $1, $2… for numbered groups, $ for named groups, and $& for the whole match.

Is my text sent anywhere?

No. Everything runs in your browser.