Unable to search the word if there are special characters in it
CaptainT33mo opened this issue · comments
Hi, I have the following array of objects: I want to search the word Powai
(case insensitive). But when I search the word I am not getting the results with the word (Powai)
with parenthesis. I have attached the code below the JSON. Please help.
[
{
"id": 31,
"name": "Powai",
},
{
"id": 3474,
"name": "Powai Chowk Mulund",
},
{
"id": 3475,
"name": "Powai Vihar Complex",
},
{
"id": 2428,
"name": "Forest Club Powai",
},
{
"id": 2635,
"name": "Hiranandani Powai Bus Station",
},
{
"id": 3561,
"name": "Ramda Hotel (Powai)",
},
{
"id": 2244,
"name": "Crisil House (Powai)",
},
{
"id": 2662,
"name": "I.R.B.Complex(Powai)",
},
{
"id": 2890,
"name": "Kingston Sez (Powai)",
},
{
"id": 3972,
"name": "Tatapower Centre (Powai)",
},
{
"id": 2362,
"name": "Dr.Ambedkar Udyan (Powai)",
},
{
"id": 2389,
"name": "E.S.I.S.Local Office Powai",
},
]
match-sorter
version:^4.1.0
node
version:12.14.0
npm
(oryarn
) version:6.14.4
Relevant code or config
matchSorter(options, inputValue, {
keys: ["name"],
threshold: rankings.WORD_STARTS_WITH,
keepDiacritics: true,
});
This is because the threshold is set to rankings.WORD_STARTS_WITH
but the word for (Powai)
starts with (
not Powai
. You'll probably want to change it to rankings.CONTAINS
.
Alternatively, you could use the function form (see "Property Callbacks" in the README.md file) and return the name with the parentheses removed.
Good luck!