Regex Generator

Give the generator a few example strings that should match — and optionally some that should not — and get a working regular expression. It analyses the common structure, produces a pattern with a plain-English explanation and validates the result against your negative examples.

How to use

1

Add positive examples

List strings that should match, one per line.

2

Add negative examples (optional)

List strings that should not match — helps refine the pattern.

3

Generate the regex

The tool produces a pattern with an explanation and test results.

4

Copy or refine

Copy the pattern or adjust examples until it fits your case.

Positive examples (one per line)
Negative examples (optional)
Generated regex
/[a-z]+@[a-z]+\.[a-z]+/g
[a-z]+lowercase letter
@literal character
[a-z]+lowercase letter
\.literal character
[a-z]+lowercase letter
All negative examples correctly rejected.
3 examples3 negatives

Features

Generates from examples

Analyses the common structure across positive examples to build a pattern.

Negative examples support

Use negative examples to detect overly broad patterns.

Explanation included

See a human-readable breakdown of what each part of the regex does.

Validation against negatives

Shows which negative examples still match the pattern.

Common use cases

  • Create a regex for validating email addresses
  • Build a pattern for phone numbers in a specific format
  • Generate a pattern for log line parsing
  • Turn a list of example strings into a reusable regex

Frequently Asked Questions

Related tools