Dev
Dummy Regex Test String Generator
A regex that passes hand-written test cases but fails on real input is one of the most common validation bugs. The strings you write yourself reflect what you already know, missing combinations you never considered. A dummy regex test string generator builds a diverse corpus automatically, up to 50 strings per run. The `type` input selects the category. 'emails' generates addresses with varied usernames and TLDs. 'urls' generates http and https URLs with random slugs and paths. 'phone numbers' generates three formats: +1-area, (area) prefix, and area.prefix. 'alphanumeric' generates mixed-case strings of 6–20 chars. 'special chars' mixes letters, digits, and symbols like !@#$%^&*(). 'mixed' selects randomly across all five per output item. Output is a plain list, one string per line, ready to paste into Regex101, a Jest test.each() array, or a Pytest @pytest.mark.parametrize block.
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Select a string type from the dropdown — choose a specific category like 'email' or 'URL' to test one validator, or pick 'mixed' for a broad dataset.
- Set the count field to the number of test strings you need; start with 20-30 for quick checks or 50+ for thorough coverage.
- Click Generate to produce the randomised list, then review the output to confirm it includes the variety you need.
- Copy the full list and paste it into your regex tester, test file, or script — each line is a separate test input ready to use.
Use Cases
- •Pasting 50 mixed strings into Regex101 to build a shareable, persistent unit-test suite
- •Feeding generated email variants into Jest's test.each() to catch subdomain and plus-addressing edge cases
- •Populating a Pytest @pytest.mark.parametrize block with phone number strings for international-format validation
- •Stress-testing an API endpoint's input filter with special-character sequences before a security review
- •Seeding a Postman collection with randomised alphanumeric IDs to verify ID-format validation logic
Tips
- →Run the generator three or four times on 'mixed' mode and merge the batches — repeated randomisation catches edge cases a single run misses.
- →After generating, manually add one or two strings you know should fail your regex — confirms your pattern rejects invalid input, not just accepts valid input.
- →Use 'email' mode when testing email validators, then switch to 'special characters' to confirm your pattern doesn't crash on inputs like `<>{}|\`.
- →Pipe the copied list into a short shell script with grep or awk to see instantly which strings match your regex before writing a single unit test.
- →For API testing, generate alphanumeric strings at count 50, then use them as randomised query-parameter values in your HTTP client's data-driven mode.
- →If your regex uses anchors (^ and $), pay close attention to multiline strings in the output — they're the most common source of unexpected match failures.
FAQ
how do I use generated strings to test a regex in regex101
Copy the output list and paste each line into Regex101's Test String field. Use the Add Unit Tests feature to mark each string as a should-match or should-not-match case, creating a persistent test suite you can revisit whenever the pattern changes. Regex101 also highlights which strings your pattern fails on, making it easy to spot gaps.
are randomly generated test strings better than hand-writing them
For catching edge cases, yes. Hand-written strings reflect what you already know, so they miss unusual combinations — phone numbers with dots rather than dashes, emails with numeric-heavy usernames, URLs with no path component. Running the generator several times and merging batches builds a broader corpus than most developers write manually.
can I use these strings directly in jest or pytest parameterized tests
Yes. Copy the list and format it as an array or list literal in your test file. In Jest, pass it to test.each(); in Pytest, use @pytest.mark.parametrize. Each string becomes a separate test case and failures are reported individually. For email or URL tests, split the generated list into expected-valid and expected-invalid sets and mark each group accordingly.
what string types cover special character edge cases for security testing
Use the 'special chars' type, which generates strings containing !@#$%^&*()_+-=[]{}|;':,.<>? mixed with alphanumeric characters. These are useful for testing input sanitization, SQL injection filter bypasses, and XSS-mitigation code. The 'mixed' type includes special characters as part of a broader corpus alongside emails and URLs, which helps confirm that your validator rejects malicious input while still accepting valid formats.
You might also like
Popular tools from other categories that share themes with this one.
Try these next
More free tools from other corners of the catalog, picked by shared themes.