ForHosting KIT · Developer Utilities

Regex tester

Check a pattern exactly as your browser will run it: hello in hello world gives one match at position 0, with its numbered and named groups listed. Switch to replace to preview a substitution before it touches real data. 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
Pattern
hello
Text
hello world
Flags
You get
Quantity
1

Need a reliable ECMAScript regex tester for patterns, capture groups and replacements? This tool runs the same engine as your browser: flags g, i, m, s, u and y, structured match results with numbered and named groups, and replace templates with $$, $&, $n and $<name>.

Match mode and capture groups

In match mode the response lists every finding with the full match text, the UTF-16 start index used by JavaScript strings, the numbered capture groups in opening order, and optional named groups when the pattern declares them. Without the global flag you get at most one match, which matches how RegExp.prototype.exec behaves for a single search. With g the engine walks non-overlapping matches and advances lastIndex after each hit.

Sticky y must match exactly at the current index and does not skip ahead over spaces or other characters, which is why gy on words separated by blanks often returns only the first token. Empty matches are advanced safely so a pattern cannot spin forever on zero-length successes.

Replace templates

Replace mode uses the ECMAScript replacement table implemented by String.prototype.replace with a string template, not a callback. Without any match the result equals the original subject text, count is zero, and matched is false, which makes identity easy to assert in automation. Prefer the same pattern and flags you would paste into a code editor so client previews and server jobs never diverge.

When you need to count how many substitutions would apply, the count field mirrors match mode for the same pattern, flags and text before the replacement string is applied.

Flags, invalid patterns and limits

Only the six flags g, i, m, s, u and y are accepted, each at most once. Length limits protect the browser tab and the worker: the pattern may be at most one thousand characters, the text at most one hundred thousand characters, and a single call may produce at most ten thousand matches.

The unicode flag u makes the dot and character classes operate on Unicode code points; without u a single emoji may occupy two UTF-16 code units, which is the same subtle behaviour developers already meet in JavaScript.

Debug patterns before shipping

Paste sample logs or form input and confirm groups and indices before putting the regex in production code.

Teach and document regex

Show match and replace side by side with the same ECMAScript rules students will use in JavaScript.

Sticky and global edge cases

Inspect how y and g interact on spaces and empty matches without guessing browser quirks.

Is the online regex tester free?

Yes. The browser tool runs locally at no charge.

Which regex flavor is used?

ECMAScript RegExp, the same engine as modern browsers and Node. It is not PCRE or Python re.

Why do I only get one match?

Without the g flag the search stops at the first match, just as a single search does in JavaScript. Add g and the tester walks through every non-overlapping match in the text.

How do I reuse a captured group in the replacement?

Use $& for the whole match, a dollar sign followed by the group number for a numbered group, and $<name> for a group you named. Write $$ when you need a literal dollar sign.

Why does the sticky flag stop after the first word?

With y the match must start exactly where the previous one ended and cannot skip spaces or other characters. On words separated by blanks, gy therefore often returns only the first word.

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/dev/regex-tester

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/dev/regex-tester \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pattern":"\\w+","text":"hello world"}'
{
  "pattern": "\\w+",
  "text": "hello world"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.regex_tester",
  "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_chars1000
max_text_chars100000
max_matches10000
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.

Match mode and capture groups

An optional group that does not participate is returned as JSON null so array slots stay stable for scripts and tests.

Replace templates

A double dollar becomes a single literal dollar sign, $& inserts the full match, $1 through $99 insert numbered captures when those groups exist, and $<name> inserts a named capture that you defined in the pattern.

Flags, invalid patterns and limits

Any other character or a duplicate returns a typed invalid_input error instead of letting the engine throw.

Bulk replace previews

Try replacement templates on a short sample, then call the API with the identical contract from a pipeline.

Which flags are supported?

g, i, m, s, u and y. Other flags or duplicates return invalid_input.

How are optional groups returned?

As null in the groups array (and in named when applicable), never omitted and never undefined in JSON.

What happens if the pattern is invalid?

You receive invalid_input with a message that starts with Regex inválida, not an untyped SyntaxError.

What are the size limits?

Pattern ≤ 1000 characters, text ≤ 100000 characters, at most 10000 matches per request.

Read the full KIT documentation →