findall

finds all regex matchings

finds all regex matchings

findall = require('findall')
 
text = 'lorem $ipsum sit $dolor amet'
 
findall(text, /($\w+)/)
['$ipsum', '$dolor']

See test.js for more info.

$ npm install findall

Never pass a variable that points an expression:

var re = /this wont work!!/
 
findall('never do this', re)

Always pass the regex itself.

findall('this will work', /whatever regex is/)