Describe it · Get the pattern · Move on

Regex Builder API

Describe what you want to match in plain English. Get a working regex with an explanation of how it works. Stop spending 30 minutes on character classes.

The problem it solves

^[\w.+-]+@[\w-]+\.[\w.-]+$

Readable? No. Debuggable in 5 minutes? Also no.

Regex is write-once-debug-forever. The pattern that works in isolation fails in production because of a format variant you didn't consider. Describing what you want in English forces you to be precise — which surfaces edge cases earlier.

How it works

Request

POST /api/tools/regex-builder

{
  "description": "Match US phone numbers
    in formats like (555) 123-4567,
    555-123-4567, or 5551234567",
  "testString": "Call us at (555) 123-4567
    or 555.987.6543"
}

Response

{
  "pattern": "\\(?\\d{3}\\)?[\\s.\\-]?
    \\d{3}[\\s.\\-]?\\d{4}",
  "flags": "g",
  "explanation": "Matches US phone
    numbers with optional parentheses,
    separated by spaces, dots,
    or hyphens",
  "matches": [
    "(555) 123-4567",
    "555.987.6543"
  ]
}

The explanation field matters

Every response includes a plain-English explanation of what the pattern does. This lets you verify the pattern matches your mental model — and iterate on the description if not. It's also useful for code review, documentation, and teaching junior devs.

🔍

Data Extraction

Pull structured values from unstructured text — dates, IDs, amounts, codes.

Input Validation

Describe the valid format for your domain-specific identifiers and get the validator.

🤖

Agent Tools

Give agents a regex tool — they describe what to match, get the pattern, apply it.

TypeScript SDK

import { AgentToolbelt } from "agent-toolbelt";

const toolbelt = new AgentToolbelt({ apiKey: process.env.TOOLBELT_KEY });

const { pattern, flags, matches } = await toolbelt.regexBuilder({
  description: "Extract ISO 8601 dates from log lines",
  testString: "[2024-03-15T14:22:01Z] ERROR: connection refused",
});

const regex = new RegExp(pattern, flags);
const dates = logLines.flatMap(line => line.match(regex) ?? []);

Pricing

Fractions of a cent per call

Get API Key →

More tools

Part of Agent Toolbelt — 14 focused API tools for AI developers