JavaScript Regex Tester

Test regular expressions with live match highlighting, capture groups, and replacement preview. Uses your browser's V8 regex engine.

/ /
Try:

Test String

0 chars

Replace

use $1 $2 for captures

Replaced Output

Matches

What are regular expressions?

Regular expressions are a miniature language for describing patterns of text. A single pattern can match phone numbers, extract email addresses, validate ISO dates, or split a log line into fields. Every major programming language, database, and text editor supports them — the syntax differs in details but the core concepts are universal: character classes, quantifiers, grouping, alternation, anchors, and backreferences.

Flavor: JavaScript (ECMAScript)

This tester uses your browser's native regex engine — the same one JavaScript code on every website uses. It supports all modern flags:

  • g — global, find every match instead of just the first
  • i — case-insensitive
  • m — multiline, so ^ and $ match line starts and ends
  • s — dotAll, lets . match newlines
  • u — unicode, enables \p{…} property escapes
  • y — sticky, matches only from lastIndex

Common pitfalls

Greedy vs lazy. By default .* is greedy — it matches as much as possible. Use .*? for lazy (match as little as possible). Greedy quantifiers inside HTML parsing are a classic source of over-matching bugs.

Anchor escaping. Inside a character class, ^ means "not" only as the first character: [^abc]. Elsewhere it means start-of-string/line. $ inside a class is literal.

Catastrophic backtracking. Patterns like (a+)+b can take exponential time on non-matching inputs. If your regex hangs the browser, simplify the nested quantifiers or rewrite with an atomic-group equivalent.