Skip to content
OneTooling

Regex Tester

Test regular expressions live. See highlighted matches, capture groups, a replace preview, and a plain-English explanation. Nothing leaves your browser.

Runs in your browser · nothing uploaded
Flags

No matches.

Replace preview

Matches

No matches yet. Change the pattern or the text.

What the pattern means

  1. (?<year>Start of capture group 1, named "year"
  2. \d{4}Any character that is a digit (0-9), exactly 4 times
  3. )End of group 1
  4. -The character "-"
  5. (?<month>Start of capture group 2, named "month"
  6. \d{2}Any character that is a digit (0-9), exactly 2 times
  7. )End of group 2
  8. -The character "-"
  9. (?<day>Start of capture group 3, named "day"
  10. \d{2}Any character that is a digit (0-9), exactly 2 times
  11. )End of group 3

Why is there an ad? This tool is free and runs on your device. One small ad pays for hosting and new tools. No pop-ups, no autoplay, never inside the tool. How we make money

How to test a regular expression

  1. Type your pattern in the box at the top, and switch flags on or off. Use g to find every match.
  2. Paste the text to search. Matches are highlighted as you type, and each one is listed with its capture groups.
  3. Type a replacement such as $1-$2 or $<name> to preview the result, and read the step by step explanation to check what each part does.

The patterns run as JavaScript regular expressions. If you plan to use the pattern in Python, Go, or another language, check the details that differ, such as lookbehind support and flags written inside the pattern.

Regex cheat sheet

Characters

.
Any character except a line break
\d \w \s
Digit, word character, whitespace
\D \W \S
The opposite of each
[abc] [a-z] [^abc]
One of, a range, none of
\. \* \(
A special character, as plain text

Position

^ $
Start and end of the text (or line with m)
\b \B
Word boundary, not a word boundary
(?=x) (?!x)
Followed by x, not followed by x
(?<=x) (?<!x)
Preceded by x, not preceded by x

Repeats

* + ?
Zero or more, one or more, zero or one
{3} {2,} {2,5}
Exactly 3, at least 2, between 2 and 5
*? +? ??
Lazy: as few as possible

Groups

(abc)
Capture group, numbered from 1
(?<name>abc)
Named capture group
(?:abc)
Group without capturing
a|b
a or b
\1 \k<name>
Repeat what a group matched

Replacement

$1 $2
Text of a numbered group
$<name>
Text of a named group
$& $$
The whole match, a literal $

Questions

Is my text uploaded anywhere?

No. The pattern and the test text are matched by your browser's own regular expression engine, so logs, emails, and other private text never leave your device.

Which regex flavor does this use?

JavaScript (ECMAScript), the engine built into your browser. It supports named groups, lookbehind, and Unicode property escapes. Features from other flavors, such as possessive quantifiers and inline flags like (?i), are not available.

Why was my pattern stopped?

Some patterns, such as (a+)+$ on a long run of "a" letters, take exponentially longer as the text grows. This is called catastrophic backtracking. Matching runs in a background thread with a two second limit, so the page never freezes. Rewrite the pattern so each part can match only one way.

How do I use a capture group in the replacement?

Write $1, $2, and so on for numbered groups, or $<name> for a named group. $& inserts the whole match, and $$ inserts a literal dollar sign. The preview updates as you type.

Why do I only see one match?

Without the g (global) flag, a regular expression stops after the first match. Turn on g to find all of them.

Credits

Built by OneTooling using standard browser features. No third-party code runs on your data.