Regex Generator API - Natural-Language to Regex Pattern
Matches a natural-language description against a library of pre-vetted patterns (email, URL, phone, date, IPv4, hex color, UUID, credit card, ZIP/postal code). When the description matches a known keyword set the endpoint returns a tested pattern with appropriate flags. Unknown descriptions fall back to an escaped, word-boundary-style pattern. Optional test_string runs the pattern and returns the matched substrings.
Code examples
curl -X POST https://api.botoi.com/v1/regex/generate \
-H "Content-Type: application/json" \
-d '{"description":"email address","test_string":"Contact us at sales@example.com or support@example.org"}'When to use this API
Regex helper in a developer tool
When a user types "match phone numbers" in your form builder, call this endpoint and drop the returned pattern and flags into the validation field. Saves users from hand-crafting regex for common shapes.
Log parsing templates
Generate patterns for UUIDs, IPs, and timestamps on demand, then pipe them into your log-pipeline config. The test_string field lets you confirm the pattern fires on a sample log line before shipping the config.
Quick validation prototypes
During API design, ask for a "credit card" or "ZIP code" pattern and plug the result straight into your Zod or Yup schema. Swap for a stricter pattern later; this gets you a working draft in seconds.
Frequently asked questions
Which descriptions are recognized?
What does the endpoint do for unrecognized descriptions?
Is the generated regex safe to run on untrusted input?
Why does test_result sometimes include the "g" flag?
Get your API key
Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.