Regex String Generator
Generate sample strings that match a regex — seeded, deduplicated and verified.
Regular expression
Pattern is parsed locally and every sample is verifiedSupported: literals, character classes, groups, alternation and bounded quantifiers. Lookarounds are ignored during synthesis but verified by the real regex engine.
Matching samples
No samples generated yet
Enter a pattern or load an example.
Regex String Generator parses a practical subset of regular-expression syntax — literals, character classes, groups, alternation and bounded quantifiers — and expands it into candidate strings using a seeded random generator. Every candidate is checked with the browser's real RegExp engine before display, so emitted strings actually match. Sampling supports deduplication and repeat caps; enumeration lists small pattern spaces completely.
Examples
Postal codes
\d{5}48291
07123
55340Each sample has exactly five digits and matches the original pattern.
Hex colors
#[a-f0-9]{6}#a3f19cThe literal hash and six-digit class are expanded in order.
Enumeration
[ab]{2} in enumeration modeaa
ab
ba
bbSmall pattern spaces can be listed completely instead of sampled.
Anchored pattern
^abc$abcAnchors do not contribute characters, so the synthesized content is verified directly.
About this tool
Regex String Generator manufactures sample strings from a regular expression instead of merely testing them. It parses literals, character classes, groups, alternation and quantifiers, then expands the resulting structure with a seeded random generator. Every candidate is verified with the browser's RegExp engine before it appears in the results.
Sampling mode produces a requested number of strings with optional deduplication, a repeat cap for * and + quantifiers, and a seed that makes runs reproducible. Enumeration mode lists every string in a small pattern space up to a configurable cap and falls back to verified sampling when the space is too large.
The tool is aimed at fixture and test-data creation. It supports case-insensitive and other matching flags, keeps non-ASCII literals intact, and reports unsupported constructs such as lookarounds and backreferences instead of silently producing wrong data.
What this tool does not do
- Supported syntax is limited to literals, classes, groups, alternation, anchors and quantifiers; backreferences, lookarounds and Unicode property escapes are not synthesized.
- Negated and shorthand classes sample from a bounded printable ASCII set, not from all Unicode code points.
- Repetition counts are clamped to keep generation bounded; unbounded quantifiers never produce arbitrarily long strings.
- Enumeration is capped at 10,000 candidate strings by default and falls back to sampling for larger spaces.
- The verifier strips g and y flags so duplicated candidates are not skipped by RegExp state.
How to use this tool
Enter a pattern
Type a regex or load an example. The pattern is parsed entirely in your browser.
Tune generation
Set the sample count, maximum repetitions, seed, flags and deduplication to control diversity.
Choose a mode
Sampling is best for large pattern spaces; enumeration lists all matches when the space is small.
Verify and export
Read the warnings about unsupported constructs, then copy or download the verified samples.
Use cases
Unit-test fixtures
Create many valid inputs for a validator without hand-writing each one.
Property-based testing
Feed generated strings into a parser to probe edge cases.
Demo data
Populate a UI with realistic values that obey a documented format.
Regex education
Show how alternation and quantifiers expand into concrete strings.
Supported syntax
| Construct | Example |
|---|---|
| Literal | abc |
| Character class | [a-z0-9] |
| Shorthand class | \d \w \s and complements |
| Group and alternation | (cat|dog) |
| Quantifier | {3}, {2,5}, *, +, ? |
| Anchors | ^ $ |
| Lookarounds and backreferences | (?=a), \1 |
Every emitted string passes a final RegExp.test check, so synthesis limitations cannot produce false positives.
Common mistakes
Mistake:Assuming generated samples are random each run.
Fix:The seed is fixed by default; change it to get a different reproducible set.
Mistake:Expecting backreferences to be synthesized.
Fix:Lookarounds and backreferences are reported as unsupported; generated candidates are still verified by the engine.
Mistake:Using an unbounded quantifier and expecting very long strings.
Fix:The repeat cap bounds * and + to a configurable number of extra repetitions.
Mistake:Requesting enumeration for a huge pattern space.
Fix:The tool estimates the space via a bounded expansion and falls back to verified sampling with a warning.
Mistake:Forgetting that g and y flags affect repeated .test calls.
Fix:The verifier strips stateful flags before testing so every candidate is checked from position zero.
Frequently asked questions
Are generated strings guaranteed to match?
Yes. Every candidate is checked with the browser's real RegExp engine before it is shown. Strings that fail verification are discarded, and the tool reports how many were rejected.
How are unbounded quantifiers handled?
The repeat cap bounds * and + to the minimum plus a configurable number of extra repetitions (four by default, up to twelve). This keeps generation finite and fast.
What about lookarounds and anchors?
Anchors contribute no characters and are ignored during synthesis; the final verification still enforces them. Lookarounds are not synthesized — the tool reports that limitation rather than emitting unverified strings.
Can it enumerate all matches?
For small pattern spaces, yes. Enumeration mode expands bounded choices into every string up to the configured cap. If the space is too large, the tool warns and returns verified samples instead.
Does it support backreferences?
No. Capturing groups are treated as ordinary groups during synthesis and backreference escapes are reported as unsupported. Verification still uses the original pattern, so no invalid string is emitted.
Is my pattern sent anywhere?
No. Parsing, generation and verification happen entirely in your browser. Nothing is uploaded or stored.
References & standards
Related tools
Anagram Solver & Palindrome
Normalize text for palindrome checks and privacy-preserving anagram analysis.
Binary Text Translator
Convert text to binary or hex bytes and decode it back
Braille Translator
Translate text to Unicode Braille and back with UEB Grade 1 letters, numbers, punctuation and a per-cell dot breakdown.
Caesar Cipher Tool
Encrypt, decrypt and brute-force Caesar shifts with English-frequency ranking and a one-click ROT13 shortcut.
Case Converter & Text Formatter
Convert text between 14 different case formats including camelCase, snake_case, kebab-case with batch processing and advanced options
Character Frequency Analyzer
Count character, letter and word frequencies for text analysis