Regex Tester

Test regular expressions against text with live match highlighting. Pure client-side.

Text · patterns · JavaScript regex

Test regular expressions against sample text with live match highlighting and capture groups. Iterate on patterns in the browser using the same JavaScript RegExp engine your front-end code will use.

Live matching Capture groups Flags (g, i, m, …) JS / ECMAScript engine No upload

What this tester is for

Regular expressions describe search patterns: validate an id format, extract a field from a log line, or prototype a replace before running it on a large corpus. A live tester shortens the loop — change the pattern, see matches immediately — without redeploying an app or writing a one-off script.

This page uses your browser’s ECMAScript regex implementation. That is ideal when the destination is JavaScript or TypeScript. It is not a perfect stand-in for PCRE, Python re, Go regexp, or Java Pattern, which differ on lookbehind, possessive quantifiers, unicode classes, and more.

How to use it

  1. Enter the pattern (without requiring slash delimiters unless you prefer them in the box) and flags such as g, i, m, s, u.
  2. Paste representative sample text — include edge cases you care about (empty lines, unicode, partial matches).
  3. Leave Live on to retest as you type, or click Test manually.
  4. Review highlighted matches and listed capture groups, then copy the final pattern into your codebase.

Flags cheat sheet

FlagEffect
gGlobal — find all matches, not only the first
iCase-insensitive
mMultiline — ^ / $ per line
sDotall — . matches newlines
uUnicode mode for code-point aware patterns
ySticky — match from lastIndex

Practical examples

Simple email-shaped check (illustration only — production email validation is harder):

Pattern: ^[^@\s]+@[^@\s]+\.[^@\s]+$
Flags:   i
Text:    dev@example.com

Capture an ISO date from a log line:

Pattern: (\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})
Text:    level=info ts=2026-03-01T14:22:10 msg=started

Group 1 is the date, group 2 the time. Named groups ((?<name>…)) work in modern browsers when you need clearer code.

Don’t parse HTML or full JSON with regex. Nested structure needs a real parser. Regex is brittle for balanced tags and escaped quotes. Use it for flat tokens and line-oriented text.

Performance & ReDoS

Some patterns (especially nested quantifiers like (a+)+$ on long a…aX strings) can run in catastrophic backtracking time. In servers that accept user-supplied regex, that is a denial-of-service risk (ReDoS). Prefer possessive-style thinking, atomic grouping where available, or non-regex parsers for untrusted input. In this browser tool, a runaway pattern may freeze the tab — keep samples realistic.

FAQ

Why does it work here but fail in Python/Java?

Dialect differences. Retest in the runtime you ship (and with the same flags). Port patterns carefully around lookbehind, unicode properties, and substitution syntax.

Do I need slashes like /pattern/gi?

In code, JS literals use slashes. This UI uses separate pattern and flags fields — paste the body of the pattern and set flags explicitly.

Is my sample text uploaded?

No. Matching runs locally. Privacy Policy.

Related tools

Sponsored