Skip to content

Tokenize a search query with refined options (like Google's) and match against a target

License

Notifications You must be signed in to change notification settings

queicherius/refined-text-search

Repository files navigation

refined-text-search

Tokenize a search query with refined options (like Google's) and match against a target.

Package Version Build Status Code Coverage

InstallationUsageContributorsLicense


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

About

Tokenize a search query with refined options (like Google's) and match against a target

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published