Skip to content

Conversation

ancms2600
Copy link

I have a list of strings in the format:

`${AccountName} (${AccountId})`

image

In one case, there were two matches for "L1 Application" but one of them had a hyphen in the account name, which caused it not to match.

I wanted a simple way to sanitize the filter candidate before the match was performed. In my case, I have it remove all non-alphaNumeric characters, like so:

$('#filterByAccount').multiselect({
    enableFiltering: true,
    filterBehavior: ({text}) => text.replace(/[^a-z0-9]+/gi, ' '),
    // ...
});

As a result, it now matches both results, as expected (see image above).

Others could theoretically use this function to do even more, such as modify what is matched on (e.g., starts-with could easily be performed by returning filter candidates that contain starting parts only, and this function could be rotated between a set of possible filter candidate generators depending on the search mode.)

see also: #803 #408

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant