---
name: regex-email-validator-builder
description: "Ready-to-paste validation regex for a common input format such as an email address, phone number, URL, IP address, password, or date, in your language's flavor, with the strict and practical versions explained. Use when a form or import needs a validation regex for a well-known format such as email, phone number, URL, IP address, password strength, or a date. Do not use for custom patterns that are not a standard format, or explaining a regex someone else wrote. Related topics: coding, regex, email."
---

# Regex Email Validator Builder

Ready-to-paste validation regex for a common input format such as an email address, phone number, URL, IP address, password, or date, in your language's flavor, with the strict and practical versions explained.

## When to use

Use this skill when a form or import needs a validation regex for a well-known format such as email, phone number, URL, IP address, password strength, or a date. Do not use it for custom patterns that are not a standard format, or explaining a regex someone else wrote.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Write a practical pattern that accepts what real users type and rejects obvious mistakes, in the chosen language's escaping.
3. Write a strict pattern that follows the relevant standard, and apply any extra rules to both versions.
4. Apply the case-insensitive flag the way the chosen flavor expects, and anchor both patterns so partial matches cannot slip through.
5. List five test strings per pattern, three matching and two failing, each failure with its reason.
6. State which pattern to use for a form field and which for data cleaning, in three sentences.

## Inputs

- **Format to validate** (choose one: Email, Phone number, URL, IP Address, Password strength, Date format)
- **Case insensitive** (choose one: Yes, No)
- **Language flavor** (choose one: JavaScript, Python, PHP, Golang, Java)
- **Extra rules** (longer free text)

## Output

Two code blocks (practical and strict pattern in the chosen language), a table of test strings with pass or fail and the reason, and a three-sentence recommendation.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Validation Regex for a Common Format

Give me a validation regex.

- Format to validate: {{Format to validate}}
- Case insensitive: {{Case insensitive}}
- Language flavor: {{Language flavor}}
- Extra rules: {{Extra rules}}

Offer two patterns: a practical one that accepts what real users type and rejects obvious mistakes, and a strict one that follows the relevant standard (RFC 5322 for email, E.164 for phone numbers, ISO 8601 for dates, IPv4 and IPv6 handled separately). Say which to use for a form field and which for data cleaning, and why. Write each pattern in the chosen flavor, with anchors, the right escaping for that language's string literals, and the case flag applied the way that flavor expects. Apply the extra rules to both versions. For passwords, build the strength rules as lookaheads and say what each one enforces. Show five test strings per pattern: three that match and two that fail, with the reason for each failure.

Return the practical pattern and the strict pattern, each in a code block for the chosen language, then a short table of test strings and results, then three sentences on which pattern to pick.

## Pitfalls

- Shipping a full RFC 5322 email regex for a signup form, which rejects valid addresses with plus signs and frustrates users.
- Validating IPv4 with a one-to-three digit class per octet, which accepts 999.999.999.999.
- Forgetting the anchors, so the pattern matches an email buried inside a string of junk.
