Developer

Regex Tester

Build a JavaScript RegExp, toggle flags, and watch matches highlight in your subject text. See every match index and capture group, preview replace with $1 / $& — all evaluated locally in your browser.

Ad placement — top banner
Flags
Uses String.prototype.replace — supports $&, $1$9, $`, $', $$.
(Enter a replacement string to preview substitution.)
Ad placement — mid rectangle

What is a regular expression?

A regular expression (regex) is a pattern language for searching and transforming text: character classes, quantifiers, anchors, groups, and backreferences. In browsers and Node.js, patterns compile to JavaScript’s RegExp object (ECMAScript semantics). The same engine is used by String.prototype.match, replace, and split — so this tool is useful for quickly tuning patterns before you paste them into Kotlin, TypeScript, or grep-like tools (keeping in mind flavor differences).

What this tool does

DroidXP’s Regex Tester builds a new RegExp(pattern, flags) from your inputs. When the pattern is valid, it runs exec in a loop (for global patterns) or once (non-global), collects start indices, full matches, and capturing groups, and renders the subject with highlighted spans. The optional replacement field previews String.prototype.replace output — including $1 / $& substitution rules. Nothing is sent to a server; your strings stay in the tab.

  • Toggle g / i / m / s / u / y to match engine options.
  • Table of matches with index and capture columns for debugging.
  • Replace preview for refactor-style workflows.

How to use this tool

  1. Step 1: Enter the pattern source (without outer slashes).
  2. Step 2: Enable flags — use g to find every occurrence.
  3. Step 3: Paste or type subject text.
  4. Step 4: Optionally set a replacement and copy the preview or match list.

Flavor note

This page uses JavaScript (ECMAScript) regexes. PCRE, POSIX, or Python regex libraries differ in advanced features (lookbehind breadth, atomic groups, recursion). For production Android or server code, verify the same pattern in your target runtime.

Frequently Asked Questions

Does DroidXP upload my pattern or text?

No. Matching runs entirely in your browser. Avoid pasting production secrets into any online tool unless policy allows.

Why do I need the global (g) flag?

Without g, JavaScript’s non-global regex stops after the first match. Turn on g to iterate all matches in the subject (and to drive replace-all behavior with replace).

Why does the page freeze on my pattern?

Catastrophic backtracking on nested quantifiers can make regex evaluation exponential. If the tab hangs, simplify the pattern, use atomic groups in engines that support them, or test in smaller steps. This tool caps iteration to protect the UI.

Does replace match PCRE or Python’s re.sub?

Replace uses JavaScript’s rules: $n for captures, $& for the whole match, $$ for a literal dollar. Other languages use different syntax (e.g. \1 in some sed dialects).

Why doesn’t my lookbehind work?

Modern JavaScript supports lookbehind in compatible engines, but older browsers may not. If a pattern fails to compile, check browser support or simplify the assertion.

Can I test binary or non-UTF-8 data?

The subject is JavaScript text (UTF-16). Binary or legacy encodings should be converted before testing here.

Is this safe for production regex validation?

It is a quick interactive aid. For security-sensitive validation (e.g. allowlists), combine with automated tests, lint rules, and review — never rely on a single browser check.