1.0.0 • Published 11 years ago
nth-match v1.0.0
nth-match
Install
npm install nth-match
Usage
var nthMatch = require('nth-match');
var source = 'hello world';
var match = nthMatch(source, /\w{2}/, 3);
console.log(match)
// > 'lo'Why not just use the /g modifier?
You might rewrite the example above as:
var matches = /\w{2}/g;
console.log(matches[3]);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
1.0.0
11 years ago
