ShiftTools ShiftTools
Zero-Upload Browser Utility

Regex Tester & Debugger

Test and debug JavaScript regular expressions live in your browser. Highlight full matches, capture groups, flags, and string replacements.

Interactive Tool Workspace

Loading local in-browser WebAssembly engine & hardware cryptographic sandbox...

Writing a regular expression blindly inside your application code and re-running a test suite twenty times just to see why a lookahead or capture group missed a line is a slow way to work. This live browser-based regex tester evaluates your pattern against real test strings on every keystroke, color-codes every full match alongside numbered and named capture groups ($1, $2), supports all standard flags (g, i, m, s, u), includes a live Find & Replace preview, and provides one-click presets for common patterns.

When a visual regex workbench beats trial-and-error in code

Regular expressions are compact and expressive, which also means a single misplaced + quantifier or unescaped dot (.) can make a pattern match far too much ("greedy matching") or nothing at all:

  • Extracting structured fields from messy server logs: Writing capture groups like \[(\d{4}-\d{2}-\d{2})\]\s+ERROR:\s+(.+) and verifying that Group $1 captures the date and Group $2 captures the error message across 50 log lines.
  • Validating form inputs (emails, Indian PIN codes, PAN/GST formats, slugs): Testing edge cases - both valid strings that must match and invalid strings that must be rejected - in a single multi-line test buffer.
  • Debugging multi-line regexes (m and s flags): Seeing immediately how ^ and $ behave when the m (multiline) flag is toggled on, or whether . crosses line breaks with the s (dotAll) flag.
  • Prototyping VS Code or String.prototype.replace() substitutions: Testing replacement strings that reference capture groups ($1, $2,
    amp;
    ) before running a bulk search-and-replace across your codebase or dataset.

Testing and debugging a regular expression step by step

  1. Enter your regular expression pattern: Type your pattern into the /pattern/ input box (or pick a starter pattern from the Common Presets menu).
  2. Toggle regex flags: Enable or disable g (Global), i (Case-insensitive), m (Multiline ^/$), s (Dot matches newline), or u (Unicode).
  3. Paste your test string: Drop realistic sample lines - including tricky edge cases - into the Test String editor.
  4. Inspect highlighted matches and capture groups: Check the inline color-coded highlights and the detailed Match Breakdown list showing exact character indices (start..end) and each captured group (Group 1, Group 2, named groups (?<name>...)).
  5. Test replacements (optional): Enter a replacement template (e.g., $2-$1) in the Replace panel to preview the transformed output text live.

Features built for fast pattern debugging

Detailed capture group and index table

Knowing that a regex matched is only half the problem when your code reads match[1] and match[2]. For every match in your test string, the inspector lists the Full Match ($0), its exact start and end character offsets, every numbered group ($1, $2...), and any ES2018 named capture groups ((?<year>\d{4})).

Live substitution (.replace()) preview

When refactoring code or reformatting dates (DD/MM/YYYY → YYYY-MM-DD), the Replace preview evaluates testString.replace(regex, replacement) live so you can verify backreferences ($1,

lt;name>) before touching your production files.

Built-in cheat sheet and verified preset library

Click any preset - such as Email Address, URL (HTTP/HTTPS), IPv4 Address, ISO 8601 Date (YYYY-MM-DD), Hex Color (#RGB / #RRGGBB), or HTML Tag - to load both the pattern and sample test strings immediately.

A real example: reformatting DD/MM/YYYY invoice dates to ISO YYYY-MM-DD

Suppose an accounting export contains dates buried inside text lines:

Invoice #1042 issued on 29/10/2026 (Due: 15/11/2026)
Invoice #1043 issued on 04/11/2026 (Due: 20/11/2026)
  1. Enter the regex pattern: \b(?<day>0[1-9]|[12]\d|3[01])\/(?<month>0[1-9]|1[0-2])\/(?<year>20\d{2})\b with flags gm.
  2. The tester immediately highlights all 4 date matches across the two lines and lists the extracted groups for Match #1 (index 24..34):
  • Full Match ($0): 29/10/2026
  • Group 1 (day): 29
  • Group 2 (month): 10
  • Group 3 (year): 2026
  1. In the Replace input, type $3-$2-$1 (or
    lt;year>-
    lt;month>-
    lt;day>
    ).
  2. The live Replace Output displays:
   Invoice #1042 issued on 2026-10-29 (Due: 2026-11-15)
   Invoice #1043 issued on 2026-11-04 (Due: 2026-11-20)
  1. Copy either the transformed text or the ready-to-paste JavaScript regex literal.

Practical tips, mistakes, and engine limits

  • Forgetting the g (Global) flag: Without the g flag, a regular expression stops right after finding the very first match in the text string. Keep g enabled whenever you want to highlight all occurrences across a document.
  • Catastrophic backtracking ((a+)+b) on long non-matching strings: Nested repeating quantifiers like (.+)+ or (\w) can cause exponential backtracking if the end of the pattern fails to match. Prefer specific character classes ([^,\r\n]+) over greedy dots (.*).
  • JavaScript RegExp engine flavor: This tool executes patterns using your browser's native ECMAScript (RegExp) engine (supporting lookaheads (?=...), lookbehinds (?<=...), and named groups (?<name>...)). PCRE-only features like recursive subpatterns ((?R)) are specific to PHP/Perl and are not part of JavaScript RegExp.

Privacy and 100% client-side execution

Developers frequently test regexes against production log excerpts, customer CSV rows, or internal URLs. Every regex evaluation and string replacement runs 100% locally in your browser's JavaScript engine with zero fetch or XMLHttpRequest calls. Your patterns and test strings never leave your device.

Quick cheat sheet of essential JavaScript Regular Expression tokens

Keep these core metacharacters in mind when building or tightening a pattern in the editor:

  • Character classes: \d matches any digit ([0-9]), \w matches any word character ([A-Za-z0-9_]), \s matches whitespace (spaces, tabs, newlines), and uppercase \D, \W, \S match their exact opposites.
  • Quantifiers: + means 1 or more, means 0 or more, ? means 0 or 1 (or makes a preceding quantifier lazy/non-greedy, like .?), and {m,n} matches between m and n repetitions.
  • Anchors & boundaries: ^ matches the start of the string (or line with m), $ matches the end, and \b matches a zero-width word boundary so \bcat\b matches "cat" without matching "category".
  • Groups & lookarounds: (abc) creates a numbered capture group, (?:abc) groups without capturing, (?=abc) asserts that abc follows (positive lookahead), and (?<=abc) asserts that abc precedes (positive lookbehind).

Related tools

Cleaning up tabular data after testing a pattern? Use CSV Cleaner or compare your before-and-after text replacements in the Diff Checker. To scrub regex-matched credentials from browser network captures, open HAR File Sanitizer. Read our full tutorial on how to use the online regex tester.

Frequently Asked Questions

Which regular expression flavor does this tester use?

It runs on your browser's native JavaScript (ECMAScript) RegExp engine, which matches the exact behavior of Node.js, TypeScript, Deno, Bun, and modern frontend web applications - including ES2018 lookbehind assertions ((?<=...)) and named capture groups ((?<name>...)).

Why is my regex only matching the first occurrence in my test string?

Make sure the g (Global) flag is active. When g is turned off, regular expression engines return after the first match they encounter.

What do the m (Multiline) and s (DotAll) flags change?

By default, ^ and $ only match the very beginning and very end of the entire text box. Enabling m (Multiline) makes ^ and $ match the start and end of every individual line. Enabling s (DotAll) allows the dot wildcard (.) to match newline characters (\n) as well.

Are my test strings or production logs sent to a server?

No. All regular expression matching, group extraction, and string replacement happen 100% locally inside your browser tab's memory.

How do I reference capture groups in the Replace box?

Use $1, $2, $3, etc., to insert numbered capture groups ( ... ),

amp; to insert the entire matched substring, or
lt;groupName> if you defined a named capture group using (?<groupName>...).

Why do I have to escape characters like . or ? or + with a backslash ``?

In regex syntax, ., *, +, ?, (, ), [, ], {, }, ^, $, |, and ` are special metacharacters. To match a literal period in a domain name (shifttools.in), write \. so the .` doesn't match any arbitrary character.