Skip to content

Regex Tester

Test JavaScript regular expressions as you type. Matches are highlighted in your sample text, every match is listed with its index and capture groups (named groups too), and a replace preview shows what String.replace would produce. Your text stays in the browser.

Runs in your browserFreeNo sign-up

Processed on your device. Files and text stay in your browser and are not uploaded to our servers. How privacy works

How to use the regex tester

  1. Type a pattern between the slashes, or pick a preset such as Email, URL, IPv4 or Date to start from something that works.
  2. Toggle flags: g finds all matches, i ignores case, m makes ^ and $ line-aware, s lets . match line breaks, u enables Unicode features.
  3. Paste sample text. Matches are highlighted on the right and listed below with their character offsets and groups.
  4. Switch on Replace preview and enter a replacement using $1, $<name> or $& to check a substitution before using it in code.

Features

  • Live highlighting of every match with alternating colours so adjacent matches stay distinct
  • Match list with start and end indices, numbered groups and named groups
  • All six JavaScript flags with plain-language explanations
  • Replace preview using the real String.prototype.replace semantics
  • Presets for email, URL, IPv4, ISO date and hex colour patterns
  • Clear error messages straight from the JavaScript engine for invalid patterns

JavaScript flavour, not PCRE

This tester runs your pattern through the browser's own RegExp engine, so results match exactly what Node.js and browsers do. Most syntax is shared with PCRE, Python and Java, but there are differences: JavaScript has no possessive quantifiers or atomic groups, no inline modifiers such as (?i) in older engines, and \p{...} Unicode classes only work with the u flag. Lookbehind (?<=...) is supported in all current browsers.

Why the g flag matters

Without g, a regex stops at the first match and String.replace only replaces the first occurrence. The tester mirrors that: turn g off to see exactly what a single-match call would return. The y (sticky) flag anchors each attempt at the previous match's end, which is useful for tokenisers but surprising elsewhere.

Limits and catastrophic backtracking

Sample text is capped at 100,000 characters and the match list at 2,000 matches to keep the page responsive. Some patterns, typically nested quantifiers such as (a+)+ applied to non-matching input, can take exponential time in any backtracking engine; if the page freezes, simplify the pattern or use an atomic-style rewrite with possessive-like constructs.

Frequently asked questions

Why does my pattern from Python or PHP behave differently here?

Each language has its own regex dialect. JavaScript lacks some PCRE features and names groups with (?<name>...) rather than (?P<name>...). Check the flags too: Python's re.VERBOSE has no JavaScript equivalent.

How do I match across multiple lines?

Enable the s flag so that . matches line breaks, and the m flag if you want ^ and $ to match at the start and end of each line rather than the whole text.

Can I use the replacement output directly?

Yes. The preview calls text.replace(regex, replacement) exactly as your code would, including $1, $<name>, $& and $$ references, so what you see is what your program will produce.

Is my sample text sent anywhere?

No. Pattern matching happens entirely in your browser's JavaScript engine; nothing is transmitted or stored.

Other tools people use alongside Regex Tester.

You might also like

Something useful from another corner of VoltKit.