Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

regjsenum

1.0.0 • Public • Published

regjsenum

NPM Version Build Status Coverage Status

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
ccc

Supports 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
A@a.aa
B@a.aa
A@A.aa
B@A.aa
A@a.Aa
B@a.Aa
A@A.Aa
B@A.Aa
C@a.aa
C@A.aa
$ regjsenum --examples '^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$' | head -n5000 | tail
bA@gs.sG
Ab@gs.sG
bb@gs.sG
1A@gs.sG
1b@gs.sG
A1@gs.sG
b1@gs.sG
11@gs.sG
AAAA@gs.sG
bAAA@gs.sG

License

MIT

Install

npm i regjsenum

DownloadsWeekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar