Regex Tester

Test regex patterns with live highlighting and capture groups.

Matches highlighted

What Does the Regex Tester Do?

The Regex Tester lets you build and debug regular expressions with instant feedback. Type a pattern, set flags and paste a test string: every match is highlighted in place, and a detail table lists each match with its position, numbered capture groups and named groups. Invalid patterns show the engine's exact error message instead of failing silently.

The tester uses JavaScript's native regex engine, so what works here works identically in browsers and Node.js — and mostly transfers to PHP, Python and other PCRE-flavored engines.

How to Test a Regular Expression

  1. Enter your pattern (without surrounding slashes) — e.g. \b\w+@\w+\.\w{2,}\b.
  2. Set flags: g (all matches), i (ignore case), m (multiline anchors), s (dot matches newline), u (unicode).
  3. Paste sample text — matching runs live as you type.
  4. Read the highlights and the group table to verify captures.

Regex Quick Reference

  • \d \w \s — digit, word character, whitespace (capitals negate: \D = non-digit).
  • + * ? {n,m} — one-or-more, zero-or-more, optional, counted repetition.
  • ^ $ \b — start of line, end of line, word boundary.
  • (…) capture group · (?:…) non-capturing · (?<name>…) named group.
  • (?=…) (?!…) — lookahead / negative lookahead.
  • [abc] [^abc] — character class and its negation.

Developers validate input patterns, data analysts extract fields from messy logs, and SEO specialists test redirect rules — all safer to debug here than in production.

Frequently Asked Questions

Why does my pattern only find the first match?

Add the g (global) flag. Without it, JavaScript regex stops at the first match — the tester defaults to g, but if you removed it, that is the cause.

What does the m flag actually change?

Only the anchors: with m, ^ and $ match at the start and end of every line instead of the whole string. It does not affect the dot — use the s flag to make . match newlines.

Will patterns tested here work in PHP or Python?

Mostly yes — core syntax (classes, quantifiers, groups, lookarounds) is shared across PCRE-style engines. Differences appear in exotic features: lookbehind support details, named-group syntax variants and possessive quantifiers.

Why does the tester stop at 5000 matches?

A guard against runaway patterns (like matching an empty string globally) keeps the browser responsive. If you legitimately need more than 5000 matches, process the text in chunks.