Regex Tester

Test regular expressions in your browser. View match groups, run replace operations, and reference the built-in cheat sheet.

Runs entirely in your browser. Nothing is sent to our servers.

/ /
Flags: g global, i case-insensitive, m multiline, s dotall, u unicode, y sticky.
Type a pattern and some input.
Common patterns (click to insert)

About this tool

This tester runs your regex against your test input using the native JavaScript RegExp engine — entirely in your browser. The highlighted view shows what your pattern matches in real time. Each match is listed with its position and capture groups below.

JavaScript regex flavour

JavaScript regex differs in a few important ways from PCRE (PHP/Perl) and Python's re module. A few notable points:

  • Lookbehind ((?<=...), (?<!...)) is supported in all modern browsers.
  • Possessive quantifiers (a++, a*+) are not supported. Use atomic groups or refactor.
  • Named groups use (?<name>...) and are accessed via match.groups.name.
  • Unicode property escapes like \p{L} require the u flag.

Replacement syntax

In the replacement field, use $1, $2, etc. to reference capture groups, or $<name> for named groups. Use $& for the entire match and $$ for a literal $.

Frequently asked questions

Why doesn't my pattern match anything when I expect it to?
Most common: forgetting the g flag (without it, only the first match is found and the highlight only shows one); using a regex anchor like ^/$ without the m flag in multi-line input; or special characters like ., (, + not being escaped when meant literally.
How do I match across newlines?
For . to match newlines, use the s (dotall) flag. For ^/$ to match the start/end of each line instead of the whole string, use the m flag. The two flags are independent.
Can this catch a catastrophic backtracking regex?
The browser will eventually finish or freeze. If your pattern locks up the page, that's a sign of catastrophic backtracking — typically nested quantifiers like (a+)+ against a long non-matching input. Refactor to be linear (anchored or with possessive-like constructs).
Are the test input and pattern logged anywhere?
No. Everything runs in your browser via the native RegExp engine. Nothing is transmitted.

Last updated: May 17, 2026