Skip to content
XUtilHub

Regex Tester – Test Regular Expressions Online

Test JavaScript regular expressions with live match highlighting, capture groups, flags and replace preview. Free online regex tester.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Regular expression
//g
Test string
Matches
Matches are highlighted here.

About the Regex Tester

Write a regular expression and see every match highlighted in your test text as you type, with capture groups, named groups and a live replace preview.

Key features

  • Live match highlighting as you type
  • Capture groups and named groups for every match
  • All JavaScript flags: g, i, m, s, u, y
  • Replace preview with $1, $<name> and $&
  • Clear error messages for invalid patterns
  • Runs locally: your test data never leaves the browser

Build and debug regular expressions

Regular expressions are powerful but easy to get wrong. Type a pattern and some test text to see every match highlighted instantly, along with its position and capture groups. Add a replacement string to preview a search-and-replace.

Quick reference

SyntaxMeaning
.Any character (except new line unless s)
\d \w \sDigit, word character, whitespace
\D \W \SThe opposite of each
[a-z] [^0-9]Character set / negated set
* + ?0+, 1+, 0 or 1
{3} {2,5}Exactly 3 / between 2 and 5
*? +?Lazy (as few as possible)
^ $Start / end (of line with m)
\bWord boundary
( ) (?: )Capture group / non-capturing group
(?<name> )Named group
a|ba or b
(?= ) (?! )Lookahead / negative lookahead
(?<= ) (?<! )Lookbehind / negative lookbehind

Useful patterns

TaskPattern
Email (simple)[\w.+-]+@[\w-]+(\.[\w-]+)+
Date YYYY-MM-DD\d{4}-\d{2}-\d{2}
Hex color#(?:[0-9a-fA-F]{3}){1,2}\b
Whole word "cat"\bcat\b
Trailing spaces[ \t]+$ (with m)
Duplicate words\b(\w+)\s+\1\b
Digits only^\d+$

Flags

FlagNameEffect
gglobalFind all matches
iignore casea matches A
mmultiline^ $ match each line
sdotAll. matches new lines
uunicodeFull Unicode, \p{L} classes
ystickyMatch only at lastIndex

Apply your pattern to a whole document with Find and Replace, or filter lines with Remove Lines Containing.

How to use the Regex Tester

  1. Type or paste your text into the input box.
  2. Choose the options you want.
  3. The result updates instantly as you type.
  4. Copy the output or download it as a .txt file.

Frequently asked questions

Which regex flavor does this use?

JavaScript (ECMAScript), as used in browsers and Node.js. Most syntax is shared with PCRE, Python and Java, but some features differ: for example, possessive quantifiers and recursion aren't supported.

Why does my pattern only find one match?

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

What do the m and s flags do?

m makes ^ and $ match at the start and end of every line instead of the whole text. s lets the dot (.) match line breaks too.

My browser froze while testing. Why?

Some patterns, such as (a+)+$, take exponential time on certain inputs (catastrophic backtracking). Avoid nested quantifiers on overlapping patterns.

Is my text sent anywhere?

No. All text tools run locally in your browser.

Do these tools support Unicode?

Yes. They handle Unicode text, including emoji and accented characters.

Last updated:

Related Text tools