Get regex matches without looping
npm install regex-matches --save
const re = require('regex-matches')
re(/\b\w*[Oo]\w*\b/, 'the quick brown fox jumps over the lazy dog');
//=> [
//=> ['brown'],
//=> ['fox'],
//=> ['over'],
//=> ['dog']
//=> ]
// Result when using capture groups
re(/\b\w*([Oo])\w*\b/, 'the quick brown fox jumps over the lazy dog');
//=> [
//=> ['brown', 'o],
//=> ['fox', 'o],
//=> ['over', 'o],
//=> ['dog', 'o]
//=> ]
MIT © Daniel Eckermann