Regex Tester

Enter a pattern and text to see each match, its index and capture groups, and try replacements.

/ /
g

g: Global match, i: Case insensitive, m: Multiline, s: Dotall (. matches newlines), u: Unicode

Match Results

0 matches

No matches found.

Replace matched patterns with another string.

Common Patterns

Regex Cheat Sheet

Character Classes

. - Any character (except newline)
\d - Digit [0-9]
\D - Non-digit
\w - Word character [a-zA-Z0-9_]
\W - Non-word character
\s - Whitespace
\S - Non-whitespace

Anchors

^ - Start of string/line
$ - End of string/line
\b - Word boundary
\B - Non-word boundary

Quantifiers

* - 0 or more
+ - 1 or more
? - 0 or 1
{n} - Exactly n
{n,} - n or more
{n,m} - Between n and m

Groups

(abc) - Capture group
(?:abc) - Non-capture group
(?<name>abc) - Named group
\1 - Backreference

Lookaround

(?=abc) - Positive lookahead
(?!abc) - Negative lookahead
(?<=abc) - Positive lookbehind
(?<!abc) - Negative lookbehind

Special Characters

[abc] - Character set
[^abc] - Negated set
[a-z] - Character range
a|b - Alternation (OR)
\ - Escape character

Type a regex without slashes, put the text to test below it, and every match is listed in order. It runs on your browser's JavaScript regex engine and the text is never sent anywhere. Matches are not highlighted in the text; they appear in a list with position and group values.

The email example on first load

The page opens with the pattern ([a-z]+)@([a-z]+)\.([a-z]{2,}), two lines of English text, and only the g flag on.

#Matchindex$1, $2, $3
1[email protected]14info, example, com
2[email protected]34support, toolneat, org
3[email protected]84sales, company, co

The index counts from 0 at the start of the text, and a line break counts as one character. The third match lost its .kr: the domain part ([a-z]+) cannot hold a dot, so it stops at company. Change it to ([a-z.]+) and co.kr is captured. A named group such as (?<user>[a-z]+) shows as user: in the list, and an empty group shows as (empty).

Flags and replace mode

g keeps searching to the end and i ignores case. m applies ^ and $ per line, and s lets . match line breaks. u treats two-unit characters like emoji as one, so \p{L} works.

In Replace Mode, with pattern (\d{4})-(\d{2})-(\d{2}), text start 2026-07-02, end 2026-12-31 and Replace With $3/$2/$1, the result is start 02/07/2026, end 31/12/2026. Without g only the first date changes. $& is the whole match and $$ gives one $. The Common Patterns cards hold 15 ready patterns, including email, Korean mobile numbers, IPv4 and Hangul syllables.

When a pattern misbehaves

If a dot matches everything, write \. for a literal dot. If <.+> runs to the end of the sentence, use <.+?> to stop at the shortest match. A repeat inside a repeat like (a+)+b explodes on failure and the page stalls. Python's (?P<name>...) must be written (?<name>...) here. Patterns that match zero characters stop after 10,000 matches.

Which language does it follow?

Your browser's JavaScript engine. Basic syntax is close to Java, Python and PHP, but lookbehind and named group syntax differ, so test again in the target language.

How do I match only Hangul?

Use the Unicode range for Hangul syllables, U+AC00 to U+D7A3, written as [\uAC00-\uD7A3]+. Adding \u3131-\u318E inside the brackets includes single jamo as well.