ForHosting KIT · Developer Utilities

Explain a regex pattern in plain language

See what each piece of a regular expression does: the sample email pattern splits into 16 explained parts with 3 capture groups, the first named user, each with its position and a plain description. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Flags
i
You get
Flavor
ECMAScript
Capturing groups
3

A regular expression can be compact enough to fit on one line while hiding several independent rules. This explainer validates an ECMAScript pattern, scans it from left to right, and labels its groups, quantifiers, character classes, anchors, escapes, alternatives, wildcards, and literal text. Each component includes its source position, nesting depth, and a plain-language description, making the result useful for review, learning, documentation, and debugging without changing or executing the pattern against private data.

Read the explanation in pattern order

Start with the components array, which follows the exact left-to-right order of the source pattern. Every entry identifies a type, preserves the original token, and reports a zero-based index and token length. Those positions let you connect an explanation to the precise characters in a long expression instead of guessing which parenthesis or question mark it describes.

The depth value shows where a token sits inside nested groups. Group-start and group-end entries make the structure explicit, while capturing groups receive their capture number in opening order. Named captures also retain their name.

Literal runs are kept together when possible, so ordinary text remains readable rather than becoming one noisy record per character. Read the entries sequentially first, then use the counts to locate the constructs that deserve closer review, such as several nested groups or numerous alternatives.

Understand groups, classes, and repetition

Groups define structure and sometimes capture text for later use. A plain parenthesis starts a numbered capture, a question-mark colon starts a non-capturing group, and named captures are reported with their declared name. Lookahead and lookbehind assertions are distinguished because they test surrounding text without consuming it.

Character classes are explained as matching one listed character, with negated classes called out and simple ranges such as A through Z summarized. Escapes receive descriptions for common categories including digits, word characters, whitespace, boundaries, backreferences, Unicode properties, and encoded characters. Quantifiers are attached conceptually to the item immediately before them: an asterisk means zero or more, a plus means one or more, a question mark means optional, and brace forms state exact, minimum, or bounded repetition.

A trailing question mark changes a repetition from greedy to lazy, so the explanation explicitly notes that it prefers fewer repetitions. These descriptions expose the building blocks without pretending to predict every possible match.

Validate syntax and recognize the flavor

The pattern is validated with the ECMAScript regular expression engine before any explanation is returned. This matters because regular-expression dialects differ: syntax copied from PCRE, Python, Java, or . NET may not mean the same thing in JavaScript, and some constructs may be rejected entirely.

Supply the expression body without slash delimiters and place optional JavaScript flags in the flags field. Validation establishes that the expression can compile; it does not prove that the expression matches the business data you intended, performs efficiently on every input, or is safe from excessive backtracking. Use the explanation to review structure, then test representative matching and non-matching samples with a regex tester.

Review an inherited expression

Turn a dense pattern from an old codebase into an ordered list of understandable constructs before modifying it.

Document validation rules

Generate structured notes for groups, allowed characters, anchors, and repetition rules used by a form or service.

Learn regular expression syntax

Compare the original tokens with concise explanations and source positions while studying ECMAScript patterns.

Which regular expression flavor does this explain?

It validates and explains ECMAScript regular expressions, the syntax used by JavaScript RegExp.

Should I include surrounding slash characters?

No. Send only the pattern body in pattern, and put any flags such as i or m in the separate flags field.

Does this tool test the pattern against my text?

No. It explains syntax only and does not need subject text. Use a regex tester separately to verify intended matches.

Can it identify named and numbered capture groups?

Yes. Capturing groups are numbered by opening order, and named groups also include their declared name.

What does a question mark after a repeat mean?

It makes the repetition lazy, so it prefers fewer repetitions, and the explanation says so explicitly. On its own right after an item, a question mark simply makes that item optional.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/dev2/regex-explain

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/dev2/regex-explain \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pattern":"^(?<user>[A-Za-z0-9._%+-]+)@([A-Za-z0-9.-]+)\\.([A-Za-z]{2,})$"}'
{
  "pattern": "^(?<user>[A-Za-z0-9._%+-]+)@([A-Za-z0-9.-]+)\\.([A-Za-z]{2,})$"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev2.regex_explain",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_pattern_chars2000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the explanation in pattern order

The summary gives a quick count, and component_counts is convenient for automated documentation or lint-style reports.

Validate syntax and recognize the flavor

Invalid syntax, unsupported flags, and duplicate flags return a typed invalid_input error rather than a partial or misleading explanation. Because the algorithm is deterministic, uses no network, and does not inspect subject text, the same pattern and flags always produce the same structured explanation in the browser and through the API.

What happens when the regex is invalid?

The request returns an invalid_input error containing the compilation problem. It does not return a partial explanation.

What does an API request cost?

The API base price is $0.002 per request. The same deterministic logic can also run in the browser.

Read the full KIT documentation →