Regex Tester and Debugger

New to regex? Click "Load example" below to see a working pattern, then change it and watch the results update.

1

Write your pattern

This is the shape of text you're looking for.

2

Paste in some text

We'll search this text for anything matching your pattern above.

3

See what matched

Every match will be highlighted here, with any capture groups broken out underneath.

Write a pattern in step 1 to see matches here.
4

Replace the matches (optional)

Type what should replace each match. Use $1, $2 to reuse a capture group's text.

Complete steps 1–3 first.

What does a regex do?

A regular expression (regex) is a small pattern language for matching text. Instead of searching for one exact word, you describe a shape — "a digit followed by three letters", "anything inside quotes", "an email address" — and the regex engine finds every part of your text that fits. That's the same tool behind search-and-replace, form validation, and log parsing in almost every programming language.

.Any character except a newline
\dAny digit (0–9)
\wAny letter, digit, or underscore
\sAny whitespace (space, tab, newline)
^Start of the string (or line, with m)
$End of the string (or line, with m)
*Zero or more of the previous token
+One or more of the previous token
?Zero or one of the previous token
{2,4}Between 2 and 4 repetitions
[abc]Any one of the characters a, b, or c
(...)A capture group you can reuse or extract
a|bEither a or b
\.A literal character (escape special symbols)

What is Regex Tester?

A regular expression (regex) is a compact pattern language for matching text — finding every email address in a document, validating a phone number format, or pulling a specific piece out of a log line. A regex tester lets you write a pattern and immediately see which parts of your sample text it matches, instead of guessing and re-running code.

This tool highlights every match live as you type, breaks out any capture groups separately, and lets you preview a find-and-replace before using it in real code.

How to use it

  1. Type or paste a regular expression pattern into the Pattern field.
  2. Toggle flags like "g" (find all matches) or "i" (ignore case) as needed.
  3. Paste your sample text into the text area — matches highlight automatically.
  4. Expand "Capture groups" to see what each (...) group in your pattern caught.
  5. Optionally fill in a replacement pattern (using $1, $2, …) to preview a find-and-replace.

How it works

The pattern and flags you enter are compiled into a native JavaScript RegExp and run directly against your sample text using the browser's own regex engine — the same engine that runs .match(), .test(), and .replace() in any JavaScript code.

Because it's the real engine, anything that matches here will match identically in JavaScript code using the same pattern.

Example

Pattern: (\w+)@(\w+\.\w+), Flag: g

Text: "Contact support@example.com or sales@example.org"
Matches: support@example.com, sales@example.org
Group 1: support / sales — Group 2: example.com / example.org

Frequently asked questions

What does the "g" flag do?

Without it, a regex only finds the first match in the text. With "g" (global), it finds every match.

Why isn't my pattern matching anything?

Check that special characters that should be literal (like a period in an email, or a dollar sign in a price) are escaped with a backslash — \. and \$ — since unescaped they mean "any character" and "end of string."

What's a capture group?

Parentheses (...) around part of a pattern "capture" that matched text separately, so you can extract or reuse it — for example (\w+)@(\w+) captures the username and domain of an email as two separate groups.

Does this use JavaScript regex syntax specifically?

Yes — it runs on the browser's native RegExp engine, so the syntax and behavior match JavaScript exactly, which may differ slightly from Python, PCRE, or other regex flavors in edge cases.

Is my text sent anywhere?

No — matching happens entirely in your browser; nothing you type is uploaded.