Skip to content

Regex Tester

Write a regular expression and see every match, group and replacement as you type.

Enter a pattern and some test text, or pick an example.
The link contains your pattern and test text.

Engine: JavaScript (ECMAScript) RegExp in your browser. Syntax differs slightly from PCRE, Python and Java.

Runs in your browser — your text is not uploaded.

How to use

  1. Type your regex into the Regular expression pattern field, without the surrounding slashes.
  2. Paste the text you want to test into Test string.
  3. Under Flags, turn on ignore case if capitalization should not matter.
  4. Open Matches to inspect each match and its capture groups.
  5. Open Explain to read a token-by-token breakdown of your pattern.

Examples

Capture a year and month

Input
2026-10-01
Output
1 match: 2026-10
group y = 2026, group m = 10

Swap username and domain in email addresses

Input
bob@example.com, amy@test.com
Output
example:bob, test:amy

Extract usernames as a list

Input
bob@example.com amy@example.com
Output
bob
amy

JavaScript regex cheatsheet

Characters

.Any character except a line break (any character with s)
\dDigit 0–9
\DNot a digit
\wWord character: letter, digit or _
\WNot a word character
\sWhitespace (space, tab, line break…)
\SNot whitespace
\tTab
\nLine feed
\uFFFFUnicode character by code
\p{L}Unicode letter (needs u flag)
\.Escaped special character: a literal dot

Classes

[abc]One of a, b or c
[^abc]Any character except a, b or c
[a-z]A character in the range a–z
[a-zA-Z0-9_]Same as \w

Anchors

^Start of text (start of line with m)
$End of text (end of line with m)
\bWord boundary
\BNot a word boundary

Quantifiers

*0 or more
+1 or more
?0 or 1 (optional)
{3}Exactly 3
{2,}2 or more
{2,5}Between 2 and 5
*?Lazy: as few as possible

Groups and lookaround

(abc)Capturing group
(?<name>abc)Named capturing group
(?:abc)Non-capturing group
\1Backreference to group 1
\k<name>Backreference to a named group
a|ba or b
(?=abc)Followed by abc
(?!abc)Not followed by abc
(?<=abc)Preceded by abc
(?<!abc)Not preceded by abc

Replacement

$&The whole match
$1Group 1
$<name>Named group
$`Text before the match
$'Text after the match
$$A literal $

Want to compare the text before and after a replacement? Paste both versions into the Diff Checker. For bulk clean-up without regex, try the Text Cleaner; to escape text for URLs use URL Encode/Decode.

FAQ

Does this regex tester support Python, PHP or .NET?

It uses your browser's JavaScript (ECMAScript) RegExp engine, not Python, PCRE or .NET. Some syntax differs between engines; the tester flags several common non-JavaScript constructs with hints.

Why does my regex find only the first match?

Without the g flag, the tester finds only the first match. Turn on global under Flags to find all matches.

Why did my regex time out?

Each run stops after one second. Nested repetition such as (a+)+ can cause catastrophic backtracking; simplify the pattern or test a smaller sample.

Is my test text uploaded or saved?

Matching runs in your browser, and the tool does not send your pattern or test text to a server. The test text is not saved between visits; the pattern, flags, replacement, list template and current tab are remembered in localStorage. Clear deletes that saved state.

Can I share a regex with its test text?

Share link copies a URL containing your pattern, test text and settings. The data is compressed, not encrypted, so anyone with the link can read it. Share link is disabled if the URL would exceed 8,000 characters.