{"uid":"cap_hX7tvXyBicydU2PC-c21c","slug":"aayat-ai-regex-explainer-ba1e21bf","name":"Aayat AI Regex Explainer","description":"Validate and explain a regular expression (JavaScript flavour): is it valid, what each part means in plain English, whether it risks catastrophic backtracking (ReDoS), and what it matches in up to 20 test strings (with groups). POST {pattern, flags, tests}.","url":"https://aayatai.com/regex/explain?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"flags":{"type":"string","maxLength":8,"description":"JavaScript flags: g i m s u y d v."},"tests":{"type":"array","items":{"type":"string","maxLength":500},"maxItems":20,"description":"Strings to try it on."},"pattern":{"type":"string","maxLength":500,"minLength":1,"description":"The regex source, without slashes, e.g. ^(\\d{3})-(\\d{4})$"}}},"responseSchema":{"type":"json","example":{"risk":null,"error":null,"flags":"","parts":[{"token":"^","meaning":"start of the text (or line with the m flag)"},{"token":"(","meaning":"start of capturing group"},{"token":"\\d","meaning":"a digit (0-9)"},{"token":"{3}","meaning":"repeat the previous item exactly 3 times"}],"tests":[{"input":"555-1234","matched":true,"matches":[{"index":0,"match":"555-1234","named":null,"groups":["555","1234"]}]},{"input":"5551234","matched":false,"matches":[]}],"valid":true,"groups":2,"pattern":"^(\\d{3})-(\\d{4})$"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_gaEzOyWocN6n3lY9Y8A_F","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Validates a JavaScript regular expression, explains each token in plain English, flags ReDoS risk, and tests it against up to 20 strings returning match groups.","exampleAgentPrompt":"Can you validate this regex and explain what each part does — `^(\\d{3})-(\\d{4})$` with no flags — then test it against '555-1234', '5551234', and 'abc-1234', and let me know if there's any ReDoS risk?","exampleUseCases":[{"title":"Debugging a complex email regex","prompt":"I have this regex `^[a-zA-Z0-9._%+\\-]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,}$` — can you explain what each token does in plain English and test it against 'user@example.com', 'bad@', 'test.email+tag@domain.co.uk', and 'no-at-sign', then tell me if it's safe from ReDoS?"},{"title":"ReDoS vulnerability check before deployment","prompt":"Before I ship this regex `(a+)+$` to production, can you check whether it has catastrophic backtracking risk and explain why each part could be dangerous?"},{"title":"Learning regex capture groups from a pattern","prompt":"Can you break down this regex `(\\d{4})-(\\d{2})-(\\d{2})` step by step and show me what groups get captured when I test it against '2024-07-15', '1999-12-31', and 'not-a-date'?"}],"resultDescription":"A JSON object containing: whether the pattern is valid, an array of token objects each with a token string and plain-English meaning, a risk field indicating ReDoS danger (null if safe), the number of capturing groups, and a tests array showing for each input string whether it matched, plus all match objects with index, full match text, named groups, and positional capture groups.","failureModes":["Invalid regex syntax returns valid:false with an error message describing the parse failure","Pattern exceeding 500 characters is rejected","More than 20 test strings causes request rejection","Malformed JSON body returns 400 error","Payment not provided results in 402 Payment Required response"],"whenToPreferThis":"Choose this endpoint when you need not just pass/fail regex validation but also human-readable token-by-token explanation, security analysis for ReDoS vulnerabilities, and batch testing against multiple sample strings — all in a single call. It is purpose-built for JavaScript regex flavor, so prefer it over generic validators when the runtime target is Node.js or browser JavaScript.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-02T00:46:34.190Z","isFirstParty":false,"canonicalSlug":"aayat-ai-regex-explainer-ba1e21bf"}