Regex Generator

AI-powered

Describe what you want to match in plain English. Get a regex pattern with a live test panel and a token-by-token breakdown.

01 — Overview

How the Regex Generator works

AI-powered natural language to regex. Generates a pattern with flags, explains each token, and lets you test against sample text with live highlighting. Built for the moments when you need a regex now and don't want to remember whether \d needs escaping.

02 — Use cases

When to use the Regex Generator

  1. 01

    Match all email addresses in a paragraph

  2. 02

    Extract URLs from a log file

  3. 03

    Validate UK postcodes or US ZIP codes

  4. 04

    Find anything that looks like a phone number

  5. 05

    Pull out semantic version strings like v1.2.3

03 — Examples

Regex Generator examples

match all email addresses except gmail

ex 01

\b[A-Za-z0-9._%+-]+@(?!gmail\.com)[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b

Matches valid email syntax but uses a negative lookahead to exclude gmail.com.

find UK postcodes

ex 02

\b[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}\b

Matches the standard UK postcode format.

match a hex color, with or without #

ex 03

#?[0-9a-fA-F]{6}\b

Matches 6-character hex codes with an optional leading #.

extract IPv4 addresses

ex 04

\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b

Matches valid IPv4 addresses with bounded octets (0-255).

04 — FAQ

Regex — frequently asked questions

Which flavor of regex does this generate?

By default the output is PCRE-compatible and runs as-is in JavaScript (ECMAScript), Python, Go, Java, and most other modern regex engines. Some flavor-specific tokens — like lookbehind in older JS engines — will be flagged in the explanation.

How do I use the generated regex in JavaScript?

Wrap the pattern in slashes with the flags after — for example /pattern/gi — or pass it as a string to new RegExp(pattern, 'gi'). Use String.prototype.match, matchAll, replace, or test depending on what you need.

What do the flags mean?

g matches all occurrences (not just the first), i is case-insensitive, m makes ^ and $ match line boundaries instead of the whole string, and s lets . match newlines. The tool picks sensible defaults but you can edit them.

Why does the explanation not match the regex exactly?

The token breakdown explains each meaningful piece — character classes, quantifiers, groups — in order. If the regex contains literal punctuation, it shows up as 'literal x' rather than as a separate token. If you spot a real mismatch, regenerate or refine the description.

Can I use this for password validation?

You can, but consider whether you actually need a regex. Most password rules — minimum length, character class requirements — are clearer when written as a sequence of small checks. Regex is a great fit for extraction and matching, less so for boolean validation against many rules.

Does the test panel save my pasted text?

No. The test panel runs entirely in your browser. Pasted text never leaves your device.

05 — Reference

Specs and further reading

The primary sources this tool follows. Where behaviour is defined by a specification, we link the specification rather than a summary of it.

  • Regular expressions guide

    MDN Web Docs — Reference for JavaScript regex syntax, flags, groups, and lookaround.

  • RegExp objects

    TC39 — The ECMAScript specification text that defines how JavaScript engines evaluate patterns.

  • PCRE2 pattern syntax

    PCRE — Syntax summary for the PCRE flavour used by PHP, nginx, and many command-line tools.

06 — Compare

How this compares to regex101

regex101 is a debugger: real-time highlighting, step-by-step explanation, unit tests, and nine regex flavours. If you're testing or fixing a pattern, use it — nothing here competes. The generate.now regex tool does the opposite job, drafting a pattern from a plain-English description. Draft here, then debug there.

Read the full comparison→

07 — More

Tools that pair with Regex

Last updated .