const matcher = require('keywords-matcher');
const collection = ['cat', 'lion', 'sandcat', 'catfish'];
const expression = 'cat -fish';
const result = matcher(expression, collection);
console.log(result); // ['cat', 'sandcat']
- ' ' (space) - Means both expressions are required
- '|' (pipeline) - Means at least one expression is required
- '-' (dash) - Means the following expression must not be met
- expression - The filtered string contains the expression
- '""' (quotes) - Means the expression is matched exactly
npm i keywords-match