npm.io
1.0.1 • Published 8 years ago

regex-matches

Licence
MIT
Version
1.0.1
Deps
0
Vulns
0
Weekly
0

regex-matches

Get regex matches without looping

travis npm version npm downloads npm license prs Welcome eslint

Installation

npm install regex-matches --save

Usage

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]
//=> ]
License

MIT Daniel Eckermann