String Generators

qc.char

Generates a single character string.

qc.string

Generates a string of random characters.

qc.string.ascii

Generates a string of random ascii characters.

qc.string.concat(gens)

This is a string specific generator combinator. It takes an array of string generators and executes each of them, concatenating the results.

var str = qc.string.concat([qc.char, qc.uint, qc.char, qc.char]);
str(size) // => 'a3,b'
str = qc.string.concat [qc.char, qc.uint, qc.char, qc.char]
str(size) # => 'a3,b'
let str = qc.string.concat([qc.char, qc.char, qc.char, qc.char]);
str(size) // => 'a3,b'

qc.string.matching(regexp)

This generator takes a regular expression and generates strings that the regular expression would match.

📘

Start and End Anchors

If you only want a string that 'looks like' your pattern, remember to specify the start ^ and end $ anchors in your regular expression, otherwise random text will be appended to the end or beginning respectively.

For example: /a/ could generate 'fgsavfbgt', /^a/ could generate 'avfbgt' and /^a$/ will generate 'a'.

The regular expression supports the i modifier which makes /^a$/i generate either 'a' or 'A'. It supports the g modifier which will make it possible for the pattern to appear multiple times in the string. So /abba/g could generate 'tjkegabbaregtabbagrt'.

❗️

Unsupported Features

Currently the pattern generator doesn't support the following regular expression features:

  • Negative lookahead (?!pattern): will throw an exception if used.
  • Lazy repeaters pattern*?