Random Data from Regex
RG-03Type a regular expression and get random strings that match it. A documented subset of regex syntax is supported, and anything outside it gives a clear error.
Runs in your browser. Nothing is uploaded.
Regular expression (one line)
Matching strings
How to use it
- Type one regular expression in the box, for example [A-Z]{3}-\d{4}.
- Choose how many strings to make, from 1 to 500.
- Press Generate and read one matching string per line.
- Fix any error shown, which names the position in the pattern, and generate again.
Supported syntax
Literal characters, escapes (\d \w \s \D \W \S \n \t \xHH \uHHHH and escaped punctuation), the dot, character classes with ranges and negation, groups with ( ) or (?: ), alternation with |, and the quantifiers *, +, ?, {n}, {n,} and {n,m}. A trailing ? after a quantifier is accepted. ^ at the start and $ at the end are accepted and ignored. A pattern written as /pattern/flags is accepted and the flags are ignored.
Limits you should know
Open-ended repeats such as * and + add at most 10 extra copies, so a+ gives 1 to 11 letters. The dot and negated classes pick from printable ASCII, not all of Unicode. A single result cannot be longer than 10,000 characters. Backreferences, lookahead, lookbehind, named groups, word boundaries, Unicode properties and possessive quantifiers are not supported and stop with an error.
Test data, not a full match enumerator
Each string is a random walk through your pattern, so every result matches it, but the picks are not an even sample of every string the pattern could match. Use it to build sample IDs, codes and test inputs. Choices use crypto.getRandomValues, and nothing leaves your browser.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Unsupported regex flag "x". Remove the flags or write the pattern without slashes. | A letter other than g, i, m, s, u or y follows the closing slash of a /pattern/ input. | Remove the flag or drop the slashes. |
Type a regular expression, for example [A-Z]{3}-\d{4}. | The box is empty. | Enter a pattern. |
Type one regular expression on a single line. | The input has more than one line. | Join the pattern onto one line. |
Questions people ask
How do I generate a random string from a regex?
Type the pattern, such as [a-z]{8}, choose how many results you want and press Generate. Each line is a random string that matches the pattern. Patterns that use unsupported features show an error with the position.
Which regex features are supported?
Literals, escapes like \d and \w, the dot, character classes, groups, alternation and the quantifiers *, +, ?, {n}, {n,} and {n,m}. Lookaround, backreferences, named groups and word boundaries are not supported.
Why does a+ never produce a very long string?
Open-ended quantifiers are capped at 10 extra repeats so results stay a reasonable size. If you want longer runs, write an exact count, for example a{50}. Counts up to 1000 are allowed.
Can it generate emails or phone numbers from a pattern?
Yes, if you can describe the shape with supported syntax, such as [a-z]{5,10}@(example|test)\.com. The values are made up and may look like real ones, so do not use them to contact anyone.
Does the regex I type get uploaded?
No. The pattern is parsed and the strings are built in your browser. Nothing is sent to a server, and the page keeps no history of what you type.
Do flags like /i or /g change the output?
The page accepts the flags g, i, m, s, u and y after a closing slash but ignores them, because they change how a pattern matches text, not which strings it describes. Any other flag letter gives an error.
About this tool
Reads a documented subset of regular expression syntax and builds strings that match it. Supported: literal characters, escapes (\d \w \s \D \W \S \n \t \xHH \uHHHH and escaped punctuation), the dot, character classes with ranges and negation, groups (capturing and (?:...)), alternation with |, and the quantifiers *, +, ?, {n}, {n,} and {n,m}. Open-ended repeats (*, +, {n,}) add at most 10 extra copies. The dot and negated classes choose from printable ASCII only. ^ and $ at the ends are accepted and ignored. Backreferences, lookahead and lookbehind, named groups, word boundaries, Unicode properties and possessive quantifiers are not supported and give an error that names the position. Flags after a closing slash are accepted and ignored. Every choice uses crypto.getRandomValues. Strings are random picks, not an even sample of all possible matches. Nothing is stored or sent.