← Back to Tools

πŸ”€ Regex Tester

Test JavaScript regular expressions against sample text, with live highlighting and match details.

Email URL IPv4 US Phone Hex Color ISO Date HTML Tag
/ /
.Any character except newline
\d \w \sDigit, word char, whitespace
\D \W \SNegated versions of above
^ $Start / end of string (or line with m)
* + ?0+, 1+, 0-or-1 repetitions
{n,m}Between n and m repetitions
[abc]Character class
[^abc]Negated character class
(...)Capturing group
(?:...)Non-capturing group
(?<name>...)Named capturing group
a|bAlternation (a or b)
\bWord boundary
(?=...)Positive lookahead
(?!...)Negative lookahead

Quick Answer

A regular expression (regex) is a pattern used to match, search, or extract text. This tester runs your pattern against sample text using JavaScript's regex engine, highlighting every match and listing captured groups β€” safely, in a background worker with a time limit so a runaway pattern can't freeze your browser.

How to use this tool

  1. Type a pattern between the slashes, or click a chip above (Email, URL, IPv4, etc.) to insert a ready-made pattern.
  2. Toggle flags: g (all matches), i (case-insensitive), m (multiline), s (dot matches newline), u (unicode).
  3. Edit the test text β€” matches highlight and update live.
  4. Optionally type a replacement string (supports $1, $2… for capture groups) to preview a find-and-replace.
  5. Open the Regex Cheat Sheet for a quick reference of common syntax.

Example

Pattern \b\w+@\w+\.\w+\b against the default text matches both email addresses. Try adding the i flag and typing [email protected] to see case-insensitive matching in action.

Privacy & safety

Matching runs entirely in your browser, in a separate Web Worker thread with a 2-second time limit. If a pattern causes catastrophic backtracking, the worker is terminated automatically instead of freezing the page β€” your text never leaves your device.

FAQ

What is catastrophic backtracking?

Certain regex patterns (like nested quantifiers, e.g. (a+)+$) can cause the engine to try an exponential number of combinations on some inputs, effectively hanging. This tool detects that by timing out and terminating the worker.

Does this match Python or PCRE regex exactly?

No β€” this uses JavaScript's native regex engine. Syntax is very similar to PCRE/Python but has some differences (e.g. lookbehind support varies by engine version).

Related Tools