Regex String Generator

Overview

Regex to Strings takes a regular expression and generates a batch of matching string examples, making it easy to verify that a pattern covers what you intended and to produce test fixture data without writing a script. The count of generated strings is adjustable from 10 to 1000, and results update in real time.

What the Result Panel Shows

The panel header reads "displayed / total possible" — for example, "10 / 468" means the expression has 468 distinct possible matches and the first 10 are shown. This total is useful for judging whether your character groups or alternations are wider than you expected.

Using the default example /(((555) ?)|(555-))?d{3}-d{4}/ produces strings like:

555 234-5678
555-012-3456
789-1234
555 901-2345
345-6789

Each string satisfies "optional 555 prefix + three digits + hyphen + four digits", showing the different paths through the ? quantifier and | alternation.

Which Syntax Can Be Expanded

The following constructs are enumerated:

  • Character classes [abc] and ranges [a-z]
  • Bounded quantifiers {n} and {n,m}
  • Optional ?
  • Groups and alternation (a|b)
  • Shorthand classes: \d (equivalent to [0-9]), \w (equivalent to [a-zA-Z0-9_])

Expressions with unbounded quantifiers (+, *, {2,}) can have infinitely many matches — the tool truncates to your set count and samples representative strings across the range.

Syntax Error Feedback

Before generating, the tool validates the expression using the browser's native RegExp constructor. An invalid regex — unclosed parenthesis, illegal escape, etc. — triggers an error message explaining the specific issue before any generation attempt is made.