Skip to content
Palmate Solutions

Data

Regular Expression (RegExp) Tester & Debugger

Interactive JavaScript RegExp tester with real-time match highlighting, capturing groups inspection, string substitution, and a curated library of production regex patterns.

Load Common Pattern:
//gi
Flags:
164 chars0.3 ms2 matches

Live Match Highlighting

Contact engineering at [email protected] or [email protected] for urgent audit tickets. Invalid formats: bad-user@, @nodomain.com.

Match Groups Breakdown (2)

#Match TextIndexLengthCapture Groups
1[email protected]2328—
2[email protected]5540—

RegExp Replacement / Substitution

Output Preview
Contact engineering at [EMAIL: [email protected]] or [EMAIL: [email protected]] for urgent audit tickets. Invalid formats: bad-user@, @nodomain.com.

How it works

The tool instantiates a native JavaScript RegExp object with your configured flags. When the global flag (g) is set, RegExp.prototype.exec() iterates through the input string, collecting match offsets, match lengths, indexed capture groups, and named capturing groups (?<name>). To prevent catastrophic backtracking (ReDoS) from freezing the UI, execution is bounded by maximum iteration safety caps.

How to use it

  1. Enter your regular expression pattern between the forward slashes (or select a preset pattern from the dropdown).
  2. Toggle flags such as g (global), i (case-insensitive), m (multiline), s (dotAll), or u (unicode).
  3. Enter or paste the test string in the text area.
  4. Review highlighted matches, match indices, and capturing group breakdowns in real time.
  5. Enter a replacement expression (e.g. $1 or [MATCH]) to test string substitution.

Worked Examples

Example 1: Extracting Domain and Username from Emails

Worked Example

Splitting enterprise email contacts into user and company domain components.

Input Payload

[email protected]

Output / Result

Full Match: [email protected] | Group 1: admin | Group 2: palmatesolutions.com

Why this happens: Capturing parentheses allow independent extraction of the local user identifier and the remote mail host.

Example 2: Validating SemVer Version Tags

Worked Example

Enforcing Git release tags to adhere to vMAJOR.MINOR.PATCH format.

Input Payload

v16.3.3-beta.1

Output / Result

Match found: Major: 16, Minor: 3, Patch: 3, Pre-release: beta.1

Why this happens: Matches numeric version segments and isolates optional pre-release semver tags for CI/CD automated packaging.

Example 3: Sanitizing PII with Substitution

Worked Example

Masking sensitive user email addresses in server log files.

Input Payload

User login event: [email protected]

Output / Result

User login event: [REDACTED_EMAIL]

Why this happens: Using replacement pattern '[REDACTED_EMAIL]' cleans customer data before publishing traces to public monitoring dashboards.

Edge Cases & Failure Modes

Catastrophic Backtracking (ReDoS)

Nested quantifiers like (a+)+ or (x+x+)+y cause exponential evaluation steps when matching non-matching inputs, which can freeze the browser thread.

Handling: Avoid nested quantifiers and test patterns with both valid and maliciously structured mismatching inputs.

Zero-Width Matches and Infinite Loops

Patterns that match empty strings (such as a* or \b) can cause infinite loops when iterating with the global (g) flag.

Handling: Our iteration engine checks for zero-length match advances and forcibly increments the lastIndex pointer to guarantee termination.

Multiline (m) vs DotAll (s) Flag Nuances

The 'm' flag makes ^ and $ match line boundaries, but does not allow '.' to match newlines. Matching across lines requires the 's' (dotAll) flag.

Handling: Enable the 's' flag when your regex needs to match text that spans across multiple carriage returns.

Privacy & Local Execution Guarantee

All regular expression compilation, pattern matching, group extraction, and string replacements run exclusively in your browser JavaScript runtime. No test strings or regex patterns are sent to remote servers.

Frequently Asked Questions

Which regular expression engine does this tester use?

This tool runs directly on your browser's ECMAScript RegExp engine (V8 in Chrome/Edge/Node, JavaScriptCore in Safari, SpiderMonkey in Firefox). Patterns behave identically to JavaScript and TypeScript applications.

What are Named Capturing Groups and does this tool support them?

Yes. Named capturing groups use the syntax (?<groupName>pattern). When matched, the group name and its captured slice appear in the Capture Groups breakdown table.

How do I reference matched groups in the replacement input?

Use $& to reference the entire matched substring, $1 for the first capturing group, $2 for the second, or $<name> for named capture groups.

Can I use lookbehind assertions in this tester?

Yes. Modern browser JavaScript engines support both positive lookbehind (?<=...) and negative lookbehind (?<!...).

API ArchitectureEngineers Available

Enterprise API Gateways & Resilient Client SDKs

Building bulletproof input validation, API routing pipelines, zero-trust parameter sanitization, and SDK wrappers for enterprise developers?

  • Zero-loss retry policies & idempotency layers
  • Production OAuth 2.0 / mTLS gateway integration
  • Fixed-timeline delivery with enterprise SLAs

Next step

Need production-grade systems, resilient APIs, or cloud infrastructure?

Our senior software architects design, build, and optimize mission-critical software systems on deterministic timelines.