Randexp

randexp

Generate a random string that matches a given RegExp.

What better way to generate a random string than with a language you can use to express the string you want? -- 🐴

Get it: npm install randexp

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
// sets and ranges and references
new RandExp(/<([a-z]\w{0,20})>foo<\1>/).gen();
// => <m5xhdg>foo<m5xhdg>

// wildcard
new RandExp(/random stuff: .+/).gen();
// => random stuff: l3m;Hf9XYbI [YPaxV>U*4-_F!WXQh9>;rH3i l!8.zoh?[utt1OWFQrE ^~8zEQm]~tK

// ignore case
new RandExp(/xxx xtreme dragon warrior xxx/i).gen();
// => xxx xtReME dRAGON warRiOR xXX

GIF FTW!

randexp.gif

Suggest a module

Comments