Regex Tester

Enter a regular expression and some test text to see every match highlighted as you type. Capture groups, named groups and a replacement preview are shown too. Uses the JavaScript (ECMAScript) regex engine in your browser.

/ /
Matches

      

Regex syntax cheat sheet

A regular expression describes a text pattern. The engine scans the test string from left to right and reports every place where the pattern fits. These are the building blocks you will use most often:

TokenMeaningExample
.Any single character except a line breaka.c → abc, a-c
\d / \DA digit 0–9 / any non-digit\d{3} → 123
\w / \WA letter, digit or underscore (ASCII only) / anything else\w+ → user_01
\sWhitespace: space, tab, line break and other Unicode spaces\s+
\bWord boundary (zero-width)\bcat\b does not match “concat”
[abc] / [^abc]One of a, b, c / any character except them[0-9a-f] → a hex digit
* / + / ?0 or more / 1 or more / 0 or 1colou?r → color, colour
{n,m}Between n and m times\d{2,4}
*? / +?Lazy versions: match as little as possible<.+?> → one HTML tag
^ / $Start / end of input (of each line with the m flag)^#
( ) / (?: )Capturing group / non-capturing group(\d+)px → $1 = 12
(?<name> )Named capturing group(?<year>\d{4})
(?= ) / (?<= )Lookahead / lookbehind (zero-width)\d+(?=%) → 50 in “50%”
a|ba or bjpg|png

Flags

FlagMeaning
gGlobal: find all matches (without it, only the first one)
iCase-insensitive
mMultiline: ^ and $ match at the start and end of every line
sdotAll: . also matches line breaks
uUnicode mode: treats emoji as one character and enables \p{…} property escapes
ySticky: match only at the current position
dGenerate start/end indices for each capture group

Using the replacement field

The replacement is applied with JavaScript's String.prototype.replace. Use $1, $2… for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign. For example, the ISO date preset with the replacement $<month>/$<day>/$<year> turns 2026-10-04 into 10/04/2026. Without the g flag only the first match is replaced.

Frequently asked questions

Will my regex behave the same in Python, PHP or Java?

The core syntax is shared, but details differ between engines. This tester uses your browser's JavaScript engine. For example, Python writes named groups as (?P<name>…), and support for lookbehind or Unicode properties varies by language and version. Test in your target language before shipping.

Why did the page freeze when I typed a pattern?

Nested quantifiers such as (a+)+$ can cause catastrophic backtracking, where the work grows exponentially with the input length (ReDoS). Reload the page and rewrite the pattern so that repetitions cannot overlap.

What is the perfect regex for email addresses?

A regex that fully follows RFC 5322 is extremely long and impractical. Use a simple pattern like the preset to catch typos, then confirm the address really exists by sending a verification email.

Is my test data uploaded?

No. Matching and replacing happen entirely in your browser, so it is safe to paste log files or other internal text.