kentcdodds / match-sorter

Simple, expected, and deterministic best-match sorting of an array in JavaScript
https://npm.im/match-sorter
MIT License
3.73k stars 129 forks source link

support regex search? #85

Closed ZiyunHe closed 4 years ago

ZiyunHe commented 4 years ago

Suggested solution:

Hi, I fount match-sorter is really useful for my large array. But I really need a regex search. Just wonder if there is a way to put regex instead of string. Or if this can be a future feature? Thank you.

kentcdodds commented 4 years ago

Hi @ZiyunHe,

Sorry, but that's out of scope for this project. I'd recommend you simply do:

const matchingItems = yourArray.filter(item => yourRegex.test(item))

There's no way for match sorter to rank results of regex. Sorry. Good luck!