refined-text-search
Tokenize a search query with refined options (like Google's) and match against a target.
Installation • Usage • Contributors • License
Installation
yarn add refined-text-search
Usage
import { tokenize, match } from 'refined-text-search'
// Tokenize a search query
const tokens = tokenize('"Hello World" my dear -"how are you" -horrible oh')
// -> [
// {term: 'how are you', exclude: true},
// {term: 'horrible', exclude: true},
// {term: 'hello world'},
// {term: 'my'},
// {term: 'dear'},
// {term: 'oh'}
// ]
// See if a tokenized query matches a string
const b = match(tokens, 'HeLLo World. My dear oh dear...')
// -> true
const b = match(tokens, 'HeLLo World.')
// -> false
const c = match(tokens, 'HeLLo World. My dear oh dear... What a horrible night.')
// -> false
Contributors
Thanks goes to these wonderful people (emoji key):
David Reeß |
This project follows the all-contributors specification. Contributions of any kind welcome!
License
MIT