# Regex Debugger — Manual

> Full feature reference for the Regex Debugger: editors, all six flags, match and group display, highlighting, and the JavaScript engine limits.

Source: https://www.jpkc.com/db/en/tools/regex/manual/

Back to the overview: [Regex Debugger](https://www.jpkc.com/db/en/tools/regex/) · Open the tool: [www.jpkc.com/tools/regex/](https://www.jpkc.com/tools/regex/)

This manual describes the **Regex Debugger** in full: every input field, every flag, how matches and capture groups are shown, what the highlighting does, and what limits the underlying JavaScript engine imposes. The tool's interface is in English, so field and button names appear here exactly as you'll see them in the live tool.

## Layout and flow

The interface has two columns. On the left are three stacked cards — **Pattern**, **Test String**, and **Matches** — with the built-in **Cheat Sheet** on the right. There is **no run button**: evaluation happens automatically as soon as you change the pattern, the text, or the flags. Edits in the two editors are slightly **decoupled (about 200 ms debounce)** so it doesn't recompute on every keystroke; a flag click takes effect immediately.

Internally: a `RegExp` object is built from your pattern and selected flags, run against the test string, and the result appears three ways — as a counter, as a match list, and as colored highlighting in the text.

## Pattern

The top editor holds your **regex pattern** — the bare expression, **without** the surrounding slashes and without trailing flags. If your code says `/\d+/g`, only `\d+` belongs here; you set the `g` via the flag toggles.

Write backslash sequences as you would in a real regular expression, so `\d`, `\w`, `\b`, and so on — **not** double-escaped as in a JavaScript string literal. You type the pattern exactly as it would appear between the slashes.

### Copy pattern

The copy button (icon) in the Pattern toolbar puts your pattern on the clipboard **in literal format**: `/pattern/flags`. The currently selected flags come along. If the pattern is empty you get a "Nothing to copy" notice instead of a copy. The format drops straight into JavaScript code.

### Clear all

The clear button (trash icon) empties **both** editors — pattern and test string — and resets the flags to the default: `g` on, all others off. Afterward the cursor returns to the Pattern editor.

## Test String

The middle editor holds the text your pattern runs against. It is **multi-line** and shows **line numbers**, which helps when working with the line-oriented flag (`m`) and with longer input. Every change to the text triggers a fresh evaluation (after a short delay).

## Flags

Below the Pattern editor sit six toggles that together form the flag string for the `RegExp` object. By default only **`g`** is on. Each toggle maps exactly to the JavaScript regex flag of the same name:

### g — global

Finds **all** matches instead of just the first. On by default in the tool. Important in practice: if `g` is **off**, the match list shows **only the first match** — that's not a bug, it's the engine's normal behavior. For most debugging tasks you want `g` on.

### i — case insensitive

Ignores letter case. `Hello` then also matches `hello` and `HELLO`.

### m — multiline

Changes the meaning of the anchors `^` and `$`: they then match **the start and end of each line** instead of just the start and end of the whole string. Without `m`, `^` only matches at the very beginning. With a multi-line test string and line numbers you see the effect right away.

### s — dotall

Lets the dot `.` also match **line breaks**. Without `s`, `.` matches any character except a newline; with `s`, that one too.

### u — unicode

Turns on full Unicode processing. Needed as soon as you use Unicode escapes like `\u{1F600}` or Unicode property escapes like `\p{L}`. Without `u`, some sequences are interpreted differently.

### y — sticky

Forces a match **exactly at the current position** (`lastIndex`), not somewhere later in the string. A special case for tokenizer-style tasks; rarely needed in interactive testing, but available.

## Matches

The bottom-left card shows the result. Top right is a counter badge: **"0 matches"**, **"1 match"**, or **"N matches"**. While the pattern is empty it reads "0 matches" and the list stays empty ("Enter a pattern to see matches"). If a valid pattern finds nothing, "No matches found" appears.

For each match the list renders an entry with:

- **Number** — a running badge (1, 2, 3 …) in the same color as its highlight in the text.
- **Match value** — the actually matched text (`match[0]`), highlighted in color.
- **Position** — shown as `pos X-Y`: the start and end index of the match in the string (zero-based).

### Capture groups (numbered)

If your pattern contains parentheses `(…)`, the match entry lists each **numbered capture group** as `Group 1:`, `Group 2:`, and so on, each with its captured substring. Groups that captured nothing in this match (`undefined`) are omitted. Numbering follows the order of opening parentheses — just like in JavaScript.

### Named capture groups

Named groups `(?<name>…)` additionally appear as their own block, shown as `<name>:` with the captured value. The tool's starting example (`(?<word>\w+)`) demonstrates this directly. Named and numbered display aren't mutually exclusive — a named group shows up in both lists.

### Highlighting in the test string

Alongside the list, the tool marks each match **directly in the test string** in color. **Four colors** rotate: matches 1, 2, 3, 4 get distinct tones, match 5 gets the first color again, and so on. So even with closely packed matches you can tell where one ends and the next begins. On every re-evaluation the old marks are cleared and set anew.

## Error display

If your pattern is syntactically invalid (e.g. an unbalanced parenthesis or an invalid quantifier), the engine can't build a `RegExp`. Then, instead of a match list, the JavaScript engine's **original error message** appears in the error field below the pattern, and the counter switches to **"Error"**. The message is the unmodified browser message (e.g. "Invalid regular expression: …") — it often points right at the problem spot.

## Cheat Sheet

On the right sits a collapsible reference (accordion) that keeps the most important regex building blocks as short tables — without leaving the page. The sections:

- **Characters** — `.`, `\d`, `\D`, `\w`, `\W`, `\s`, `\S`, `\n`, `\t`.
- **Quantifiers** — `*`, `+`, `?`, `{n}`, `{n,}`, `{n,m}` plus the lazy variants `*?` and `+?`.
- **Groups** — `(…)`, `(?:…)`, `(?<name>…)`, backreferences `\1` and `\k<name>`, alternation `(…|…)`.
- **Anchors** — `^`, `$`, `\b`, `\B`.
- **Lookaround** — `(?=…)`, `(?!…)`, `(?<=…)`, `(?<!…)`.
- **Character Classes** — `[abc]`, `[^abc]`, `[a-z]`, `[A-Za-z]`, `[0-9]`.
- **Flags** — the six flags `g/i/m/s/u/y` with a short explanation.

## Engine and limits

The debugger is **purely client-side** and uses the browser's native **JavaScript `RegExp` API**. There's no server call, no data transfer; pattern and text stay on your device. From that follow the key facts and limits:

- **You're testing the JS engine.** Results apply 1:1 to JavaScript/Node.js/TypeScript — but not necessarily to PCRE (PHP), Python `re`, Go, or `.NET`. Differences are in the [tips](https://www.jpkc.com/db/en/tools/regex/tips/#javascript-regexp-is-not-pcre).
- **Only these six flags.** `g/i/m/s/u/y`. The `d` flag (match indices) and the `v` flag (extended classes) are not available as toggles.
- **No replace.** The tool is a pure **matcher/debugger**. It shows matches and groups but offers **no find-and-replace** and no `String.replace` preview. When you replace, you build the pattern here, test it, and carry it into your code.
- **JavaScript feature set.** Available: named groups, lookahead and lookbehind, backreferences, and (with `u`) Unicode property escapes. **Not** available: PCRE quirks like atomic groups, possessive quantifiers, recursion, `\A`/`\Z`/`\z`, or POSIX classes `[[:alpha:]]`.
- **Zero-length matches** (e.g. `\b` or `a*` at empty spots) are handled correctly: the tool prevents the infinite loop a global match on such patterns would otherwise trigger.
- **Catastrophic backtracking is possible.** Since everything runs in the browser thread, a pathological pattern (nested quantifiers like `(a+)+$`) can briefly freeze the tab on certain inputs. That's not a tool bug but a property of backtracking engines — details and remedies in the [tips](https://www.jpkc.com/db/en/tools/regex/tips/#avoiding-catastrophic-backtracking).

For the introduction, the audiences, and the big picture, see the [overview page](https://www.jpkc.com/db/en/tools/regex/). Concrete walkthroughs are in the [examples](https://www.jpkc.com/db/en/tools/regex/examples/). You can try all of it directly in the [tool](https://www.jpkc.com/tools/regex/).

