Regex Generator

Describe what to match in plain English and get a tested regular expression, checked against your examples if you give them.

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

Example

Input
{
  "description": "This is a test input for automated capability testing."
}
Answer
{
  "flags": "g",
  "regex": "This is a test input for automated capability testing\\.",
  "explanation": "Matches the literal string 'This is a test input for automated capability testing.' - 'This is a test input for automated capability testing' matches the exact phrase, and '\\.' matches the literal period at the end. The 'g' flag finds all occurrences.",
  "test_results": [
    {
      "input": "This is a test input for automated capability testing.",
      "match": "This is a test input for automated capability testing.",
      "matches": true
    },
    {
      "input": "This is a test input for automated capability testing",
      "match": null,
      "matches": false
    },
    {
      "input": "this is a test input for automated capability testing.",
      "match": null,
      "matches": false
    },
    {
      "input": "This is a test input for automated capability testing. This is a test input for automated capability testing.",
      "match": "This is a test input for automated capability testing.",
      "matches": true
    }
  ]
}

Inputs

FieldTypeRequiredWhat it is
descriptionstringYesWhat to match in natural language
test_stringsarrayNoOptional strings to test against

Output fields

How reliably each field appears in a successful answer.

FieldTypeAppears
flagsstringAlways (present in every successful answer)
regexstringAlways (present in every successful answer)
explanationstringAlways (present in every successful answer)
test_resultsarrayAlways (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-generate",
    "inputs": {
      "description": "This is a test input for automated capability testing."
    },
    "max_price_cents": 5
  }'

Limitations

  • Complex patterns need testing and refinement

    AI-generated regex — complex patterns with edge cases may need refinement and testing against your full dataset

    What to do instead: Test the generated regex against both matching and non-matching examples before deploying in production

  • Output size cap per call

    Structured output is limited to about 800 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

Related tools