Code & Scripts

    Regex without the headache.

    Describe the pattern you want to match, or paste a regex and ask what it does. Works for JavaScript, Python, PCRE, .NET, Go, and Java. Free to try.

    Used by 99,000+ developers, analysts, and admins

    Try it

    Free to try. No credit card. 5 generations on us.

    What you'll get

    A real output for a real prompt.

    Regex Generator

    Describe the pattern or text you need help with

    Generate a regex that validates US phone numbers with optional country code and separators

    Need inspiration? Try one of these prompts:

    Generate a regex that validates US phone numbers with optional country code and separatorsExplain the pattern ^(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$ used for password validationExtract order IDs like ORD-12345 from multi-line log entriesExplain how named groups (?<user>[A-Za-z]+)@(?<domain>[\w.-]+) parse email addresses

    Action

    GenerateExplain

    Results

    Nobody writes regex from memory. Anyone who tells you they do is either lying or hasn't tried to match an email address recently.

    The real workflow is: have a vague idea of what you want to match, Google “regex for X,” copy something from Stack Overflow, find out it doesn't quite work for your case, and spend 45 minutes tweaking it while slowly losing your mind.

    This tool replaces that loop. Describe the pattern in plain English. Get a regex that works, for the flavor you're using, with each piece of the pattern explained.

    Two directions

    You can go the other way too. Paste a regex you found somewhere, and ask what it matches. Useful when you inherit code, or when you're reviewing a PR and the reviewer wrote something clever that you're 70% sure is correct.

    Regex flavors

    Different languages use different regex engines. Most of the overlap is fine, but the edge cases matter. We support JavaScript (ECMAScript), Python (re module, plus regex for the expanded Unicode stuff), PCRE (PHP, Apache, and most “just regex” tools), .NET, Go's RE2, and Java's java.util.regex.

    Pick the flavor in the toggle. The generated pattern uses syntax that actually works in that engine. Lookbehind in JavaScript, for example, only works in modern engines. We'll flag it.

    Common asks we see

    Email validation (the real one, not the 10-line monster from Stack Overflow). URL matching. Phone numbers with and without country codes. Date formats. Extracting text between delimiters. Password validation with specific rules (at least one uppercase, one number, etc.). Log line parsing.

    One honest warning about email regex

    There is no regex that perfectly validates every possible valid email address. The official spec allows things like comments and quoted strings inside local parts that nobody actually uses. What you want is a regex that catches the 99.9% of real emails and rejects obvious garbage. That's what we'll give you.

    Common questions.

    Guides & tutorials.

    In-depth Regex Generator walkthroughs from our library — the how and the why behind what this tool generates.

    Pattern Building Blocks

    Quantifiers & Matching Behavior

    Groups & Lookarounds

    Search & Replace Operations

    Flavors & Engines

    Validating User Input

    +1 more guides

    Matching Web & Data Formats

    +1 more guides

    Pairs well with.

    Stop wrestling with syntax.

    Start free