◯ Free: 5 uses/day • Resets in 18h 31m
Development & Technical

Regex Generator

Describe what to match and get a tested regular expression for your language, explained token by token.

Learn more

The Regex Generator writes a regular expression from a description of what should match, in the flavor you actually run — JavaScript, Python, PCRE, Go's RE2, Java or .NET — and then proves it: every token is explained, your examples of strings that must and must not match are checked, and the pattern comes with extra test cases, a usage snippet in your language and a note on the edge cases it deliberately excludes. It also tells you when a requirement cannot be met in your flavor, such as look-behind in Go, instead of silently producing a pattern that will not compile.

0 / 3000
0 / 10000
0 / 10000

✓ Free to use — no signup, no credit card.

Developers

Company email addresses only

Signup validation that rejects free webmail domains

See input + output preview

Input

What should the pattern match?
Email addresses on the company domains acme.com and acme.co.uk, case-insensitive. Reject everything else, including gmail and addresses with nothing before the @.
Regex flavor
JavaScript / TypeScript
Examples that must match (one per line)
[email protected] [email protected]
Examples that must not match (one per line)
[email protected] @acme.com
Strictness
Practical (readable, covers common cases)

Output (excerpt)

```javascript
/^[a-z0-9._%+-]+@acme\.(?:com|co\.uk)$/i
```

**Flags:** `i` — domains and local parts are compared case-insensitively.

| Token | Meaning |
|---|---|
| `^` … `$` | the whole string must be the address |
| `[a-z0-9._%+-]+` | local part: one or more letters, digits or the common punctuation |
| `@acme\.` | literal @acme. — the dot is escaped |
| `(?:com\|co\.uk)` | exactly one of the two company domains |

| Input | Expected | Why |
|---|---|---|
| `[email protected]` | match | plain local part, allowed domain |
| `[email protected]` | match | dot in local part, second domain |
| `[email protected]` | no match | domain not in the list |
| `@acme.com` | no match | empty local part |
| `[email protected]` | no match | anchored, nothing may follow |…
All audiences

ISO 8601 calendar dates

Pull dates out of log lines before parsing them

See input + output preview

Input

What should the pattern match?
ISO calendar dates like 2026-09-20 anywhere inside a line of text. Month 01-12, day 01-31. Do not match 2026-13-01 or 26-09-20.
Regex flavor
Python (re)
Examples that must match (one per line)
deployed 2026-09-20 at 05:01 2024-02-29
Examples that must not match (one per line)
2026-13-01 26-09-20
Strictness
Strict (rejects everything invalid)

Output (excerpt)

```python
r"(?<!\d)(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(?!\d)"
```

**Flags:** none. The pattern is not anchored because the date sits inside a line.

| Token | Meaning |
|---|---|
| `(?<!\d)` | not preceded by a digit — rejects `12026-09-20` |
| `(\d{4})` | four-digit year, captured |
| `(0[1-9]\|1[0-2])` | month 01-12 |
| `(0[1-9]\|[12]\d\|3[01])` | day 01-31 |
| `(?!\d)` | not followed by a digit |

**Edge cases:** the pattern does not know month lengths — `2026-02-31` matches. Validate with `datetime.date.fromisoformat()` after extracting, which the usage snippet shows…

Your Regex Generator results will appear here

Expect clean code blocks with comments, plus a short explanation of what changed.

How to Use Regex Generator

  1. Describe what the pattern should match in plain language, including what it must reject — 'company email addresses, not free webmail' is better than 'emails'.
  2. Pick the flavor you will run it in. Go, JavaScript, Python, Java, .NET and PCRE differ in look-around support, Unicode handling and escaping.
  3. Paste a few strings that must match and a few that must not, one per line. The pattern is checked against every one of them.
  4. Choose strictness: 'Practical' for readable patterns that cover normal input, 'Strict' for validation, 'Lenient' when you capture broadly and filter afterwards.

Use Cases

1

Validate form input such as postal codes, licence plates or internal ID formats

2

Extract dates, invoice numbers or order references from log lines and emails

3

Build a search-and-replace for a bulk clean-up in an editor or a migration script

4

Explain a legacy pattern a colleague left in the codebase by pasting it as the description

5

Convert a pattern from one flavor to another when moving a script from Python to Go

Tips for Best Results

  • Give must-not-match examples — they do more to sharpen a pattern than must-match examples do.
  • If you need it inside a language string, ask for that flavor: the escaping is part of the answer.
  • For user-facing validation, pick 'Strict' and read the edge-case section before shipping.
  • A pattern with nested repetition on untrusted input can hang your server; the output warns you when that risk exists.

Frequently Asked Questions

Which regex flavors are supported?

JavaScript and TypeScript, Python's re module, PCRE (PHP, Ruby, Perl), Go's RE2 engine, Java and .NET. The pattern is written as a literal in the chosen language, with the escaping that language needs.

Does it test the pattern?

Every example you supply is listed in a test table with the expected result and the reason. The tool also adds boundary cases — empty input, whitespace, near misses — so you can see what would slip through.

Why does it say my requirement is impossible in Go?

Go's RE2 engine guarantees linear-time matching and therefore has no look-ahead, look-behind or back-references. When the description needs one of those, the tool says so and offers the closest pattern that RE2 can compile, usually with a small check in code.

What is the difference between Practical, Strict and Lenient?

Practical patterns are readable and cover the inputs you actually see. Strict patterns reject every string that is not valid, at the cost of length and readability — use them for validation. Lenient patterns capture broadly so you can filter in code afterwards — use them for extraction from messy text.

Can it explain a regex I already have?

Yes. Paste the existing pattern into the description with 'explain this' and the output walks through it token by token, lists what it matches, and points out any risk of catastrophic backtracking.

🔒
Your Privacy is Protected

We keep your input and the result for up to 90 days to run the service, prevent abuse and, if you're signed in, show your history. They are processed by the AI providers listed in our Privacy Policy. We don't sell them.

Related tools

Try this agent

API Automation AgentDescribe an automation in plain English → REST/webhook recipe → curl + Python + Node samples…Try this agent →

Related workflow

Prepare for ExamsTurn your notes into active study materialsRun workflow →

Read more