Skip to content
100% Privacy — Files Stay On Your Device
>_
English

Regex Tester

Test regular expressions with live highlighting, capture groups, and a replace preview — entirely in your browser.

//g

Engine: JavaScript (ECMAScript) regular expressions, run by your browser. Behaviour can differ from PCRE, Python, Go, Java or .NET.

Flags
Explain pattern

Enter a pattern to see it explained token by token.

Pattern library

Click a pattern to load it (with sample text) into the tester.

One case per line. Start with "+ " if the pattern must match, or "- " if it must NOT match (the g and y flags are ignored here).

Generate code

Enter a pattern to generate code.

The pattern is copied as written (only named groups, flags and replacement tokens are adapted). Check lookbehind, backreferences and Unicode support in the target engine.

Quick reference
  • \d — any digit (0–9)
  • \w — any word character (letter, digit, underscore)
  • \s — any whitespace character
  • . — any character except a line break
  • ^ — start of string (or line, with the multiline flag)
  • $ — end of string (or line, with the multiline flag)
  • * — zero or more of the previous token
  • + — one or more of the previous token
  • ? — zero or one of the previous token
  • {n,m} — between n and m repetitions
  • (...) — capturing group, (?:...) — non-capturing group
  • \b — word boundary, | — alternation (OR)

How does testing a regex in the browser actually work?

A regular expression is a compact pattern language for matching text — everything from "does this look like an email address" to "find every phone number in this document" to "strip HTML tags from this string." The catch is that regex syntax is notoriously easy to get subtly wrong: a `.` that should be escaped, a greedy `*` that swallows more than intended, a group that isn't capturing what you expect. Writing one blind and only finding out it's wrong once it's already running against production data is a bad way to learn that lesson.

This tool runs entirely on JavaScript's own built-in `RegExp` engine, executing directly in your browser the moment you type — there's no server involved, so whatever text you're testing against (which might be real user data, log lines, or anything else you'd rather not paste into a third-party service) never leaves your machine. Because it's the exact same engine your JavaScript code will run in production, what you see here — which characters match, how greedy quantifiers behave, whether a group captured anything — is exactly what you'll get at runtime, not an approximation from a different regex flavor.

Type a pattern and flip on the flags you need: `g` to find every match instead of stopping at the first one, `i` for case-insensitive matching, `m` to make `^` and `$` match the start/end of each line rather than the whole string, `s` to let `.` match newlines too. Every match in your test string is highlighted live, and each one is broken down below into its full matched text, its position, and any capture groups — including named groups like `(?<year>\d{4})` — so you can immediately see whether the group you meant to extract is actually the one that matched. The Replace section shows exactly what `String.replace()` would produce with your pattern and a replacement string, including group backreferences like `$1` or `$<year>`.

The quick-reference panel below covers the tokens people forget most often mid-task — the difference between `*` and `+`, what a non-capturing group `(?:...)` is for, how `\b` marks a word boundary — without needing to leave the page to look them up. Once you've got a pattern that behaves the way you want against realistic test data, it's ready to drop straight into your code. If you need to validate or reformat the surrounding data itself, the JSON Formatter & Validator and Text Diff Checker tools are natural companions.

Frequently asked questions

Will a bad regex pattern freeze the page?

No — matching runs in a separate Web Worker with a hard timeout, so even a catastrophic-backtracking pattern can't lock up your tab.

Does it show named and numbered capture groups?

Yes — every match lists its numbered groups and any named groups like (?<year>\d{4}).

Can I preview a replacement before using it in code?

Yes — the Replace panel shows exactly what String.replace() would output, including group backreferences.

Related tools