Google/Bing search style string matching.
yarn add string-match-like-search-engines
import stringMatch from 'string-match-like-search-engines'
// stringMatch(stringToCheck, pattern, options)
stringMatch('A good day for hot dogs and smoothies', 'hot dogs') // returns true
stringMatch('A good day for hot dogs and smoothies', 'dog hot') // returns true
stringMatch('A good day for hot dogs and smoothies', 'hot cats') // returns false
stringMatch('A good day for hot dogs and smoothies', '"hot dogs" smoothies -burgers -"cold beer"') // returns true
Notes:
- If
patternis not a string,stringMatchjust return truthiness ofpattern.
defaultOptions = {
stringDelimiter: '"',
caseSensitive: false
}
yarn test