Regex Tester
Test a JavaScript regular expression against sample text — see every match with its position, plus positional and named capture groups.
Input
Written without the surrounding slashes — e.g. \d+, not /\d+/.
Output
| # | Matched Text | Start | End | Capture Groups |
|---|---|---|---|---|
| No data yet | ||||
Guides
The Regex Tester matches a JavaScript regular expression against sample text and shows exactly what it found — every match's text, its start/end position, and any capture groups it grabbed along the way. It's built for the everyday loop of writing a pattern, running it against real data, and immediately seeing whether it's too greedy, too narrow, or just wrong.
How it works
Enter a pattern (without the surrounding slashes — write \d+, not /\d+/) and a block of test text. The tool compiles a native JavaScript RegExp from your pattern and the flags you enable, then walks every match in the text, reporting:
- Matched Text — the exact substring each match consumed
- Start / End — the character offsets of the match within the test string
- Capture Groups — both positional (
1,2, …) and named ((?<name>...)) groups, so you can confirm a group captured what you expected — or see(no match)when an optional group didn't participate
Five flag checkboxes mirror JavaScript's regex flags:
- g (global) — find every match instead of stopping at the first one. Uncheck it to preview "first match only" behavior, which changes what
^/$and lookaround effectively see. - i (ignore case) — case-insensitive matching
- m (multiline) —
^and$match the start/end of each line, not just the whole string - s (dot-all) —
.matches newlines too - u (unicode) — full Unicode-aware matching (proper handling of surrogate pairs,
\p{...}Unicode property escapes, etc.)
If the pattern has invalid syntax — an unclosed bracket, a bad escape — the tool reports it as a validation error on the pattern field rather than crashing, so you get a specific error message ("Invalid regular expression: ...") instead of a blank result.
How to use it
- Enter your pattern in Regular Expression Pattern.
- Toggle the flag checkboxes you need (global is on by default).
- Paste or type your Test String.
- Results update automatically: a Summary line ("3 matches found") and a Matches table with every match's text, position, and groups.
- Use the table's copy/download actions to grab the results as CSV.
Why are named groups also shown by number?
A named group (e.g. (?<domain>...)) still occupies a positional slot in the match — it's both "group 2" and "domain" at once. The table lists it under both, so you can cross-reference a pattern using positional backreferences ($2) against one using named ones ($<domain>) without guessing which number a name maps to.
Is there a limit on input size?
Yes — the test string is capped at 50,000 characters, and the tool reports at most 1,000 matches per run, to keep pattern testing fast and predictable even against a very large paste. Split larger text into chunks if you need to test more.
Does this run on your servers?
No — matching happens entirely in your browser using the same regex engine as any other JavaScript in the page. Your pattern and test text are never sent anywhere unless you explicitly use the API.
I don't have test text yet — I just want to understand the pattern
Use the Regex Explainer instead — it parses a pattern's structure and describes what it does in plain English, without needing anything to match it against.
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/regex-tester \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"pattern": "\\w+@\\w+\\.\\w+",
"flagGlobal": "true",
"testString": "Contact us at hello@example.com or support@iotoo…"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `regex-tester` tool (Regex Tester) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.