Regex
POST/v0/regex
Validates a regular expression pattern. Checks whether the pattern compiles successfully with the given flags. Returns the list of named capture groups found in the pattern.
Request Body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
| pattern | string | Yes | The regular expression pattern to validate |
| flags | string | No | Regex flags (e.g. gi, ms). Valid flags: d, g, i, m, s, u, v, y |
Example Request
curl -X POST https://api.isvalid.dev/v0/regex \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"pattern": "^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$", "flags": "i"}'Response Fields
| Field | Type | Description |
|---|---|---|
| valid | boolean | Whether the pattern is a valid regular expression |
| pattern | string | The pattern as provided |
| flags | string | null | The flags used for validation |
| namedGroups | string[] | List of named capture groups found in the pattern |
| error | string | Error message when the pattern is invalid (only present when valid is false) |
Example Response — valid
{
"valid": true,
"pattern": "^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$",
"flags": "i",
"namedGroups": ["year", "month", "day"]
}Example Response — invalid
{
"valid": false,
"error": "Invalid regular expression: /[/: Unterminated character class"
}