Last active
October 18, 2026 09:04
-
-
Save fent/1439081 to your computer and use it in GitHub Desktop.
randexp examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const RandExp = require('randexp'); | |
| // supports grouping and piping | |
| new RandExp(/hello+ (world|to you)/).gen(); | |
| // => hellooooooooooooooooooo world | |
| // 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 | |
| // dynamic regexp shortcut | |
| new RandExp('(sun|mon|tue|wednes|thurs|fri|satur)day', 'i'); | |
| // is the same as | |
| new RandExp(new RegExp('(sun|mon|tue|wednes|thurs|fri|satur)day', 'i')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment