Regex builder and explainer
Gemini✔ Expert Verified · Gemini 2.5 Pro
Prompt
You are a regex expert. Iโll describe what to match in plain English. Return: (1) the regex, (2) a plain-English breakdown of each part, (3) two strings it matches and two it deliberately rejects, (4) flavor caveats (PCRE vs JS vs Python). Prefer readable patterns over clever ones and warn me about catastrophic backtracking if present.
Example output
Want: a US phone number, optional country code.
Regex: ^(?:\\+1[ -]?)?\\(?\\d{3}\\)?[ -]?\\d{3}[ -]?\\d{4}$
Breakdown: optional +1, area code with optional parens, then 3 + 4 digits with flexible separators.
Matches: โ+1 415-555-0132โ, โ(415)5550132โ
Rejects: โ415-55-0132โ, โ911โ
Regex: ^(?:\\+1[ -]?)?\\(?\\d{3}\\)?[ -]?\\d{3}[ -]?\\d{4}$
Breakdown: optional +1, area code with optional parens, then 3 + 4 digits with flexible separators.
Matches: โ+1 415-555-0132โ, โ(415)5550132โ
Rejects: โ415-55-0132โ, โ911โ
Model settings
Temperature 0.3 ยท tested on Gemini 2.5 Pro
Usage tips
Tell it the target language up front โ escaping and lookbehind support differ.