ToolsEssential

Regex Tester

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

Runs in your browserNothing loggedFree
//
Matches
#MatchGroupsIndex

How to use the regex tester

  1. Type your pattern between the slashes and choose flags.
  2. Paste test text. Every match is highlighted as you type, and the table lists each match with its capture groups and position.
  3. Enter a replacement to preview the result of a find-and-replace, using $1, $2… for captured groups or $& for the whole match.

The tester uses your browser’s JavaScript regex engine, so results match exactly what String.match() and String.replace() do in Node.js and the browser. Most syntax is shared with Python, PHP (PCRE) and Java, but some advanced features differ.

Flags

FlagMeaning
gGlobal — find all matches, not just the first
iCase-insensitive
mMultiline — ^ and $ match at the start and end of each line
sDot-all — . also matches line breaks
uUnicode — enables \p{…} property escapes and correct handling of emoji
ySticky — match only at the current position

Regex cheat sheet

PatternMatches
.Any character except a line break
\d / \DA digit / not a digit
\w / \WA word character (letter, digit, underscore) / not one
\s / \SWhitespace / not whitespace
[abc] / [^abc]Any of a, b, c / anything except them
^ / $Start / end of the string (or line with m)
* + ?0 or more, 1 or more, 0 or 1
{3} {2,5}Exactly 3, between 2 and 5
*? +?Lazy versions — match as little as possible
(…) / (?:…)Capture group / non-capturing group
(?<name>…)Named capture group
a|ba or b
(?=…) / (?!…)Lookahead / negative lookahead
\bWord boundary

Useful patterns

  • Bangladesh mobile number: ^(?:\+?88)?01[3-9]\d{8}$
  • Simple email check: ^[^\s@]+@[^\s@]+\.[^\s@]+$
  • Date YYYY-MM-DD: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
  • Hex colour: ^#?([0-9a-f]{3}|[0-9a-f]{6})$ with the i flag
  • Extra spaces: {2,} — replace with a single space

Real-world validation (especially for email addresses) is more complex than any short regex. Use patterns like these for quick checks, and rely on proper validation on the server.

Frequently asked questions

Which regex flavour does this tester use?

JavaScript (ECMAScript), as implemented by your browser. It matches Node.js behaviour exactly and is very close to PCRE, Python and Java for common patterns.

Why does my pattern only find one match?

Add the g (global) flag to find every match.

How do I match a literal dot or bracket?

Escape it with a backslash: \. matches a dot, \( matches an opening bracket.

Is my text sent anywhere?

No. Matching happens in your browser.

More developer tools

See all →