pattern-string-generator
v1.0.3
Published
generates random strings based on pattern
Readme
This tiny library allows you to create random Strings, that match a given pattern.
Installation
npm i pattern-string-generator
Usage
The generator uses a set of lists, which can be combined to create a wide range of strings.
In the example above uppercase vovels are mixed with uppercase consonants and some numbers. You can also exclude parts of the pattern from being replaced by surrounding it with / as shown above.
Pre-build Lists
- 0 => Single digit number [0-9]
- V => Uppercase vovel [AEIOU]
- v => Lowercase vovel [aeiou]
- C => Uppercase consonant [BCDFGHJKLMNPQRSTVWXYZ]
- c => Lowercase consonant [bcdfghjklmnpqrstvwxyz]
- U => Uppercase letter [A-Z]
- l => Lowercase letter [a-z]
- L => Alphanumeric [A-Za-u0-9]
- s => Special Character [!§$%?=#+*~-_;./()]
- a => Alphanumeric + Special Character [A-Za-u0-9!§$%?=#+*~-_;./()]
- H => Hex [0-9A-F]
- f => Random color name
- g => Random greek letter name
Adding your own List
You can add your own List for replacement to the generator. It can either be a string or an array.
generator.addPatternList('k', ['po', 'ro', 'do'])
If you call the pattern method after this line every k in the pattern willbe replaced with either po, ro or do.
Pattern Complexity
If you want to check, how many possible results your pattern can have you can use the patternComplexity method.
