UNPKG

fuzzystringmatch

Version:

a small library that creates a in-memory index for a fast and fuzzy lookup of search terms

17 lines (16 loc) 560 B
function prepareTerm(term) { return term .toLowerCase() .trim() //.replace(/[^ a-z0-9äöü]/g, '') .replace(/,/g, '.') .replace(/^"(.*)"$/, '$1') //things like "gibson guitar" .replace(/\-/g, ' ') //usually used as a seperator .replace(/\\'\\'/g, '"') //specialty from our splunk logging lib .replace(/\\'/g, '"') //specialty from our splunk logging lib .replace(/\s+/g, ' ') .split(' ') .slice(0, 6) .join(' ') } module.exports = prepareTerm