Regex Tester

Test regular expressions against text with match details and plain-English explanations

POST 1 credit /v1/regex-test
curl -X POST "https://devtools.toolkitapi.io/v1/regex-test" \
  -H "Content-Type: application/json" \
  -d '{"pattern": "\\b[A-Z][a-z]+\\b", "text": "Hello World from Alice and Bob", "flags": "g"}'
import httpx

resp = httpx.post(
    "https://devtools.toolkitapi.io/v1/regex-test",
    json={"pattern": "\\b[A-Z][a-z]+\\b", "text": "Hello World from Alice and Bob", "flags": "g"},
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/regex-test", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"pattern": "\\b[A-Z][a-z]+\\b", "text": "Hello World from Alice and Bob", "flags": "g"}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "valid": true,
  "pattern": "\\b[A-Z][a-z]+\\b",
  "flags": "g",
  "match_count": 4,
  "matches": [
    {"match": "Hello", "start": 0, "end": 5, "groups": [], "named_groups": {}},
    {"match": "World", "start": 6, "end": 11, "groups": [], "named_groups": {}},
    {"match": "Alice", "start": 17, "end": 22, "groups": [], "named_groups": {}},
    {"match": "Bob", "start": 27, "end": 30, "groups": [], "named_groups": {}}
  ],
  "explanation": "`\\b` — Word boundary; `.` — Any character; `+` — One or more of the preceding"
}

Try It Live

Live Demo

Description

Test regular expressions against text with match details and plain-English explanations

How to Use

1

1. Send a POST request with a JSON body containing `pattern` and `text`.

2

2. Add the `flags` field to control matching behaviour — `g` for global (all matches), `i` for case-insensitive, `m` for multiline, `s` for dotall, `x` for verbose.

3

3. Inspect the `matches` array for full details: the matched text, start/end positions, captured groups, and named groups.

4

4. Read the `explanation` field for a quick English breakdown of the regex tokens found in your pattern.

About This Tool

Regex Tester validates a regular expression pattern, runs it against your text, and returns detailed match information including character positions, capture groups, named groups, and a plain-English explanation of the pattern's components.

The tool uses Python's `re` module under the hood, which supports a PCRE-like syntax. You can run a single match (default) or use the `g` flag for global matching to find every non-overlapping occurrence.

Why Use This Tool

Frequently Asked Questions

Which regex flavor is used?
Python's `re` module, which is similar to PCRE but has some differences — for example, lookbehinds must be fixed-width.
What does the `g` flag do?
Without `g`, only the first match is returned (like `re.search`). With `g`, all non-overlapping matches are returned (like `re.finditer`).
Can I use named groups?
Yes. Use `(?P<name>...)` syntax. Named groups appear in the `named_groups` object for each match.

Start using Regex Tester now

Get your free API key and make your first request in under a minute.