Generate Strings
This operation returns strings matched by the Term rather than another Term, which makes it the usual way to turn a specification into test data or fixtures.
The strings are distinct within a call, and you control how many are returned and where in the language they come from.
Basic usage
The two main parameters are:
limit: the maximum number of distinct strings to return, between 1 and 100offset: the number of strings to skip before collecting results, useful for pagination
You get fewer than limit strings when the Term's language holds fewer than that.
Code
Notice that all five strings share the same path: a path is one of the shapes the Term allows, here beta-____. By default, generation expands one path in full, shortest first, before moving to the next one, which is the cheapest way to page through a whole language but makes a small sample look repetitive. String Generation Ordering covers how to spread a sample across paths and shuffle it into natural-looking data.
Paginating with offset only returns a consistent sequence of strings if the Term's automaton is deterministic. If you only ever read from offset 0, this does not affect you. See Determinism.
Bounding string length
minLength and maxLength restrict generation to strings within a length window. Excluded strings are never enumerated at all, so they do not consume offset positions either.
Code
Restricting the character set
charset restricts generation to a set of characters, given as a character class such as [a-z] or \P{C}. Paths needing a character outside of it are dropped entirely, so the strings they would have produced are never enumerated and do not consume offset positions either. When you omit it, every character the Term allows is used.
This is the practical way to keep generated data printable or ASCII-only when the Term itself allows the whole of Unicode.
Code
Going further
Try the options interactively in the live demo, or read String Generation Ordering for the full set.