nth-match
Install
npm install nth-match
Usage
var nthMatch = ;var source = 'hello world';var match = ; console// > 'lo'
/g
modifier?
Why not just use the You might rewrite the example above as:
var matches = /\w{2}/g;console;
but this will give slightly different results. nth-match
allows overlaps in matches:
['he', 'el', 'll', 'lo']
whereas using the /g
modifier gives:
['he', 'll', 'wo', 'rl']
License
MIT