piapia123
en

Generate Sample Data from a Regex

Web

Everything runs locally in your browser — nothing is uploaded

Input
Drop a file here to load its contents
Output

The slow part of writing a regex is rarely the regex itself — it is producing data to test it with. Edge cases like extra subdomains, hyphens and optional groups are easy to miss by hand. This tool builds data from the structure of the pattern, and every sample it returns really matches. There is one hard rule: each sample is verified with a real regex engine as it is generated. If one fails, you get an internal error instead of the data — because a sample that looks right but does not match would mislead you when you test your own pattern. Only the syntax the generator understands is supported (literals, character classes, quantifiers, groups, alternation, `\d \w \s` and their negations). Lookaround, backreferences and named groups report an error rather than quietly producing something wrong. Everything runs in your browser — your pattern and the samples never leave the page.

Features

  • One regex per line, several patterns at once
  • Supported: literals, `.`, classes `[a-z]` `[^0-9]`, quantifiers `* + ? {n,m}`, groups, alternation `|`, `\d \w \s` and capitals
  • Anchors `^ $` are ignored when generating, but samples are still verified by the real engine
  • Every sample verified with `new RegExp` before it is shown
  • Unsupported syntax (lookaround, backreferences, named groups, `\b`, `\p{…}`) reports an error
  • Character set preference: ASCII, digits only, Chinese, or everything with punctuation
  • A random seed makes a batch reproducible
  • Copy a single sample, or all of them

How to use

  1. Type one regular expression per line (several are fine)
  2. Adjust samples per pattern, the total limit, or the character set
  3. Samples appear in the result area — green means verified
  4. Set a seed if you want the same batch again

FAQ

Are the samples guaranteed to match?
Yes. Every sample is tested again with a real regex engine (`new RegExp`), and only matching ones are returned. The generator builds, the engine verifies — kept separate so the tool never grades its own work.
Why do some patterns raise an error?
Lookaround `(?=`, backreferences `\1`, named groups `(?<name>`, word boundaries `\b` and Unicode properties `\p{…}` are not implemented. Rather than guess at data that fails to match, the tool tells you which construct it cannot handle — wrong data would mislead you when testing your pattern.
What is the random seed for?
Random data changes every run, which is awkward when writing docs, recording a demo or reproducing a bug with a colleague. A seed gives you a fixed batch — but remember it is pseudo-random and must never be used for passwords or keys.
Is my data uploaded?
No. Parsing, generation and verification all happen in your browser. No request is made, and it works offline.

Related tools