regjsenum
v1.0.0
Published
Enumerate matched strings for a given regular expression.
Maintainers
Readme
regjsenum
Enumerate matched strings for a given regular expression.
Install:
npm install regjsenum
const enumerate = require('regjsenum').enumerate;
for (const string of enumerate(/(ab|c){3}/)) {
console.log(string);
}
// prints:
ababab
cabab
abcab
ccab
ababc
cabc
abcc
cccSupports forced finite output:
const enumerate = require('regjsenum').enumerate;
for (const string of enumerateExamples("abc\\w*.*def")) {
console.log(string);
}
// prints:
abcdef
abcAdef
abc.def
abcA.def
abcbdef
abcb.def
abc..def
abcA..def
abcb..def
abc1def
… (long but finite list of matching examples)Comes with a tiny cli:
$ regjsenum '^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$' | head
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]$ regjsenum --examples '^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$' | head -n5000 | tail
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]License
MIT
