Regex tester & debugger — JavaScript RegExp with highlights & capture groups

Use this free online regex tester to prototype JavaScript regular expressions before you drop them into code review, CI guards, or form validation. Toggle standard RegExp flags (global, ignore case, multiline, dotAll, unicode, sticky, and indices), watch live match highlighting on your sample text, and inspect numbered and named capture groups in a sortable-style table. Everything executes locally in the browser—ideal when you need a fast regex debugger without installing a desktop app.

Flags

Active flags: gi

Highlighted matches

Matches use a warm highlight; zero-width matches show a thin marker at the position.

The the quick brown fox jumps over the lazy dog. Line two: hello hello world.

Match list

2 matches found.

#IndexFull matchGroups
10The the
  1. The
259hello hello
  1. hello

What is a JavaScript regex tester?

A JavaScript regex tester is a focused scratchpad where you edit a RegExp pattern, point it at a realistic string, and immediately see whether the engine accepts the syntax and which substrings match. Unlike guessing inside a large codebase, the feedback loop here is visual: compile errors surface in plain language, successful matches render with highlights, and each row in the results grid explains capture groups so you can confirm parentheses line up with the data you intend to extract.

This implementation deliberately mirrors ECMAScript RegExp semantics. If you are migrating configs from YAML or JSON, validate those payloads first with our YAML to JSON converter and JSON formatter, then layer regex filters on top of the normalized text.

How to use this regex debugger (step by step)

  1. Enter the pattern body only—omit the / delimiters you might type in a script. Escapes such as \d or \s work the same as in source code.
  2. Select flags with the checkboxes. Start with g when you expect multiple hits, add i for case-insensitive matching, and enable m or s when your subject spans multiple lines.
  3. Paste a representative subject into the test string field. Include both positive examples and tricky negatives so you can spot false positives early.
  4. Read the highlighted preview for coverage, then scan the match list for indexes, the full match, and every capture. When you need to compare two drafts of a pattern side by side, paste both outputs into our code diff checker.

Regex flags cheat sheet (g, i, m, s, u, y, d)

g (global) keeps searching after the first success; without it, only the first match is reported—mirroring how String.prototype.match behaves in many scenarios. i folds ASCII case; pair it with u when you rely on Unicode-aware character classes or property escapes. m changes ^ and $ so they align to line starts and ends, while s lets . swallow newline characters—handy for logs and HTML snippets you also analyze with our HTML formatter or XML formatter.

Capture groups, backreferences, and named groups

Each pair of unescaped parentheses creates a numbered capture, available as $1, $2, … inside replacement strings, or as \1 inside the pattern for backreferences. Named groups use the (?<name>…) syntax; when present, the debugger lists them by name so you can align regex extraction with object keys in your application layer.

When to pair regex with text and SEO utilities

Regular expressions shine for structured-but-noisy text: extracting IDs from URLs, normalizing whitespace, or splitting CSV-like fragments before you feed data into spreadsheets. When the task is bulk substitution rather than inspection alone, combine this page with the find and replace tool (plain text or regex). For marketing and SEO workflows that start from live pages—not arbitrary strings—use meta tags extractor and canonical tag checker to pull HTML attributes first, then apply regex only on the fragments you export.

Related free developer tools

Explore the full code and developer tools section on the home page, or open a focused utility below.

Frequently asked questions

What is a regex tester and debugger?
A regex tester runs your pattern against sample text in the browser so you can see every match, its index, and captured groups without deploying code. This debugger highlights matches in the subject string, surfaces JavaScript RegExp syntax errors immediately, and helps you tune flags like case-insensitive (i) or multiline (m) before you paste the pattern into production.
Which regex flavor does this tool use?
It uses JavaScript's built-in RegExp engine—the same rules as modern browsers and Node.js. That means features like named capture groups (?<name>…), Unicode property escapes (with the u flag), and dotAll (s flag) work when your runtime supports them. It is not PCRE, Python, or Ruby regex; those dialects differ in edge cases and advanced features.
Why do I need the global (g) flag?
Without g, a JavaScript regex stops after the first match. That is correct when you only want to test anchoring or a single replacement. With g, match iteration continues through the whole subject, which is what you usually want when validating find-all style rules. This page's match table follows that behavior: one row per match when g is enabled, otherwise a single match row when the pattern succeeds.
What is the difference between capturing and non-capturing groups?
Parentheses ( ) create capturing groups, numbered from left to right; they fill columns in the match table and backreferences like \1. (?: … ) is a non-capturing group—it groups logic without saving a slice of the match. Use non-capturing groups when you need precedence or alternation but do not want extra capture indices.
Why does my pattern throw "Invalid regular expression"?
The engine rejected the pattern at compile time—often an unclosed bracket, a bad escape, or a flag incompatible with your syntax (for example, lookbehind in very old engines). Fix the source, escape literal braces and backslashes when needed, and confirm you are not mixing regex delimiters from another language (slashes are not typed here—only the raw pattern body).
Can this tool validate email, URL, or HTML with 100% accuracy?
Regular expressions can approximate formats, but email and HTML are surprisingly subtle in the real world. Use this tester to explore a pattern and its false positives on your own samples, then prefer dedicated parsers or platform validators for critical paths. Pair complex text work with our find-and-replace and code-diff tools when you are editing configs or migrations in bulk.
Does my pattern or test text leave this page?
No. Matching runs entirely in your browser with the native RegExp API—nothing is sent to a server. You can safely prototype patterns on internal sample strings, though you should still avoid pasting secrets into any web form out of habit.
How do multiline (^ $) and dotAll (.) interact?
By default, ^ and $ anchor to the start and end of the whole string. The m flag makes them match line boundaries inside the subject. Without the s flag, . does not match newline characters; with s (dotAll), . spans across lines. Combining m and s is common for log or config snippets—test both on representative multiline samples here.
What are catastrophic backtracking risks?
Some nested quantifiers (for example (a+)+ on certain inputs) can make the engine try an enormous number of paths and appear to hang. Online testers—including this one—cannot fully sandbox CPU time. If the page stutters, simplify the pattern, use possessive-style workarounds where supported, or break validation into smaller steps.