Regex Generator
Paste sample strings and get a regular expression that matches every one of them.
Build a regex from samples
Samples: 0
Pattern: —
Self test: not run yet
How to use the Regex Generator
- Paste a few sample strings, one per line, that the pattern must match.
- Choose the match mode and how digits should be written.
- Click Build regex, read the self test result and copy the pattern.
Features
- Infers a pattern from two or more samples
- Detects dates, emails, URLs, numbers and word shapes
- Whole string, whole word or anywhere match modes
- Self test reports how many samples the pattern matches
Advertisement
Frequently Asked Questions
Common questions about the free online regex generator.
Paste one sample per line, choose the match mode, then click Build regex. The pattern appears
in the box with a self test result underneath.
Two or three lines are enough for a useful pattern. More samples keep the tool from
overfitting to a single example.
Whole string wraps the pattern in anchors, whole words adds word boundaries, and anywhere
leaves the pattern free to match inside a longer text.
It recognises ISO dates, email addresses, http and https URLs, fixed or variable length
numbers, word shapes and repeated token layouts.
When samples differ in ways the tool cannot generalise safely, it returns each sample as an
escaped alternative so the pattern still matches them all.
It counts how many of your samples the generated pattern actually matches, so you can spot a
pattern that is too narrow or too loose.
The output uses JavaScript syntax and is compiled with the u flag. Most engines accept it,
but check escape rules if you target another language.
Switch the digits option from character class to escape sequence and the pattern will use a
backslash d instead of a bracketed class.
No. The pattern is inferred inside your browser and your samples never leave the page.
Yes. The generator is fully responsive and the pattern can be copied into any mobile editor
or shell.
Last updated: October 10, 2026