Regex Explainer

Explain a regular expression in plain English, piece by piece, and optionally test it against sample strings.

Pay by wallet (x402) AI-generated regex-explain

Example

Input
{
  "regex": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
}
Answer
{
  "breakdown": [
    {
      "token": "^",
      "explanation": "Anchors the match to the start of the string"
    },
    {
      "token": "[a-zA-Z0-9._%+-]+",
      "explanation": "Matches one or more characters that are letters (upper/lowercase), digits, or the special characters . _ % + -"
    },
    {
      "token": "@",
      "explanation": "Matches the literal @ symbol"
    },
    {
      "token": "[a-zA-Z0-9.-]+",
      "explanation": "Matches one or more letters, digits, dots, or hyphens for the domain name"
    },
    {
      "token": "\\.",
      "explanation": "Matches a literal dot (escaped with backslash)"
    },
    {
      "token": "[a-zA-Z]{2,}",
      "explanation": "Matches 2 or more letters only for the top-level domain (TLD)"
    },
    {
      "token": "$",
      "explanation": "Anchors the match to the end of the string"
    }
  ],
  "plain_english": "This regex matches standard email addresses with a local part containing alphanumeric characters and special symbols, followed by an @ symbol, a domain name, and a top-level domain of at least 2 letters.",
  "capture_groups": 0,
  "common_matches": [
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ],
  "flags_detected": {
    "g": false,
    "i": false,
    "m": false
  },
  "original_regex": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
  "common_non_matches": [
    "[email protected]",
    "user@domain",
    "user [email protected]",
    "@example.com",
    "[email protected]",
    "[email protected]"
  ]
}

Inputs

FieldTypeRequiredWhat it is
regexstringYes—
test_stringsarrayNo—

Output fields

How reliably each field appears in a successful answer.

FieldTypeAppears
breakdownarrayAlways (present in every successful answer)
plain_englishstringAlways (present in every successful answer)
capture_groupsintegerAlways (present in every successful answer)
common_matchesarrayAlways (present in every successful answer)

How to call it

The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.

# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
  -H "Authorization: Bearer $STRALE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "capability_slug": "regex-explain",
    "inputs": {
      "regex": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
    },
    "max_price_cents": 5
  }'

Limitations

  • Engine-specific features may be incompletely explained

    Explains standard regex syntax — engine-specific features (PCRE2 lookbehinds, .NET named groups) may not be fully documented

    What to do instead: Specify the target regex engine in the input for more accurate explanations of engine-specific syntax

  • Output size cap per call

    Structured output is limited to about 1,500 output tokens per call; requests exceeding this limit are refused rather than returned truncated. The `test_strings` array has no input-count cap, but each string adds a test result that can exceed the output limit; an identical retry does not help.

    What to do instead: Provide fewer test_strings per call