Test Regular Expressions

/…/g

Type a pattern and see every match highlighted in your text, with its position and capture groups. Add a replacement to preview a find and replace before you run it in code.

  • Free
  • Runs in your browser
  • Live highlighting
  • No sign-up
How it works

How It Works

Debug a pattern in three steps.

01

Write the pattern

Type it without the surrounding slashes and tick the flags you need.

02

Paste test text

Matches are highlighted and listed with their index and groups as you type.

03

Try a replacement

Optionally enter replacement text, with $1 or $<name> for groups, and copy the result.

About

Testing a regular expression

Regular expressions describe text patterns: \d{3} is three digits, ^ is the start of a line, (\w+)@ captures the part of an email before the @. They are compact and easy to get slightly wrong, so testing against real samples before putting a pattern into code saves debugging time. This tester uses your browser's JavaScript engine, so a pattern that works here works the same in JavaScript and TypeScript.

Regex flavors differ. Python, PHP (PCRE), Java and .NET support features JavaScript lacks, such as possessive quantifiers, and the other way round. Check the syntax for your language if you will run the pattern elsewhere.

Five flags

g (all matches), i (ignore case), m (^ and $ at each line), s (. matches newlines) and u (Unicode).

Capture groups

Each match lists its numbered groups, or named groups when the pattern uses (?<name>…).

Replacement preview

See the full text after replace(), using $1, $& or $<name> exactly as JavaScript does.

Clear errors

An invalid pattern, such as an unclosed bracket, shows the browser's error message.

Features

Why Use This Regex Tester

See exactly what your pattern does.

Highlighted matches

Alternating colors make it easy to see where one match ends and the next begins.

Match table

Index, matched text and groups for each match, up to 1,000 counted and 200 listed.

Find and replace

Preview the result of a replacement on the whole text.

Private

Log files and data you test against stay in your browser.

✓ No Registration✓ Free✓ Browser-based✓ Text Stays Local
FAQ

Frequently Asked Questions

Questions people ask about the Regex Tester.

JavaScript (ECMAScript), as built into your browser. It supports lookahead, lookbehind, named groups and Unicode property escapes such as \p{L} with the u flag.