RegEx Tester API
Test and debug regular expressions live. Match highlighting, capture group inspection, flag toggles, and pattern explanations — 100% client-side.
The RegEx Tester is also available as a free REST API. Send a POST request with a JSON body to https://dot.tools/api/tools/regex-tester — no authentication, no API key, CORS enabled. Successful calls return { "ok": true, "result": { … } }; failures return HTTP 400 or 422 with an error body.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
pattern | string | required | The JavaScript regular expression pattern (without slashes). Capped at 500 characters as a ReDoS guard. |
text | string | required | The test text to match against. Capped at 100,000 characters as a ReDoS guard. |
flags | object | required | Regular expression flags. |
Response
| Field | Type | Required | Description |
|---|---|---|---|
valid | boolean | required | Whether the pattern compiled successfully. |
error | unknown | required | Parse error message when the pattern is invalid. |
matchCount | number | required | Total number of matches found. |
truncated | boolean | required | Whether the matches list was capped at 1000 entries. |
matches | object[] | required | All matches (capped at 1000). |
explanation | object[] | required | Token-by-token explanation of the pattern. |
Example request
curl -X POST https://dot.tools/api/tools/regex-tester \
-H 'Content-Type: application/json' \
-d '{
"pattern": "(?<user>[\\w.+-]+)@(?<domain>[\\w-]+\\.[\\w.]+)",
"text": "Contact us:\n support@bitgate.com\n sales@bitgate.com\n kevin.schipper+tools@bitgate.com\n\nInvalid entries:\n not-an-email\n @missing-user.com\n missing-at-sign.com",
"flags": {
"global": true,
"ignoreCase": false,
"multiline": true,
"dotall": false,
"unicode": false,
"sticky": false
}
}'Sample response
{
"ok": true,
"result": {
"valid": true,
"error": null,
"matchCount": 3,
"truncated": false,
"matches": [
{
"index": 1,
"text": "support@bitgate.com",
"range": [
14,
33
],
"groups": [
{
"index": 1,
"name": "user",
"value": "support"
},
{
"index": 2,
"name": "domain",
"value": "bitgate.com"
}
]
},
{
"index": 2,
"text": "sales@bitgate.com",
"range": [
36,
53
],
"groups": [
{
"index": 1,
"name": "user",
"value": "sales"
},
{
"index": 2,
"name": "domain",
"value": "bitgate.com"
}
]
},
{
"index": 3,
"text": "kevin.schipper+tools@bitgate.com",
"range": [
56,
88
],
"groups": [
{
"index": 1,
"name": "user",
"value": "kevin.schipper+tools"
},
{
"index": 2,
"name": "domain",
"value": "bitgate.com"
}
]
}
],
"explanation": [
{
"token": "(?<user>",
"description": "start of named capture group 1 \"user\""
},
{
"token": "[\\w.+-]",
"description": "any single character in this set"
},
{
"token": "+",
"description": "preceding token repeated one or more"
},
{
"token": ")",
"description": "end of group"
},
{
"token": "@",
"description": "literal \"@\""
},
{
"token": "(?<domain>",
"description": "start of named capture group 2 \"domain\""
},
{
"token": "[\\w-]",
"description": "any single character in this set"
},
{
"token": "+",
"description": "preceding token repeated one or more"
},
{
"token": "\\.",
"description": "literal \".\""
},
{
"token": "[\\w.]",
"description": "any single character in this set"
},
{
"token": "+",
"description": "preceding token repeated one or more"
},
{
"token": ")",
"description": "end of group"
}
]
}
}Use the free RegEx Tester in your browser, read the RegEx Tester guide, or import the full OpenAPI specification.