← Docs
Recipe

NL → regex with explanation

Turn plain-English descriptions into precise regular expressions with inline commentary so you understand every token.

Prompt

Write a regex that matches a valid IPv4 address. After the regex, add a line-by-line breakdown of what each part does.

Output

^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}
(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$

^ — anchor to start of string

(?:...) — non-capturing group for one octet

25[0-5] — matches 250–255

2[0-4][0-9] — matches 200–249

[01]?[0-9][0-9]? — matches 0–199 with optional leading digits

\\. — literal dot separator

{3} — repeat the octet-plus-dot group three times

$ — anchor to end of string

Tips

  • Ask for the breakdown explicitly — models skip it otherwise.
  • Specify the regex flavor (PCRE, JavaScript, Python) if it matters.
  • Request non-capturing groups for cleaner match results.