Generates a random string of given length using a given set of characters.
The set of characters is described using JavaScript regular expressions.
For example, [aeiou]
matches lowercase vowels,
[0-9A-F]
matches digits and uppercase letters.