Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple search terms without fuzzy-search plugin #371

Closed
claudiodestasio opened this issue Dec 8, 2015 · 1 comment
Closed

Multiple search terms without fuzzy-search plugin #371

claudiodestasio opened this issue Dec 8, 2015 · 1 comment

Comments

@claudiodestasio
Copy link

Sorry for my bad english ;)
I need to specify multiple search terms and the fuzzy-search plugin does not work (for me) with very long strings in li elements.
They are not practical with javascript but hacking the code would find a solution with the following change using regex (lines 1000 to 1005 about):

values: function(values, column) {
            if (values.hasOwnProperty(column)) {
                text = toString(values[column]).toLowerCase();

                 var searchRegex = "(?=.*"+searchString.replace(/(?:\W+)/g,")(?=.*")+").*";
                 var searchRegexObj = new RegExp(searchRegex,"i");


                if ((searchString !== "") && (text.search(searchRegexObj) > -1)) {
                    return true;
                }
            }
            return false;
        }

It 'a too expensive solution in terms of resources? Is there a more elegant way to achieve the same result?

@javve
Copy link
Owner

javve commented Feb 24, 2016

I've been thinking about allowing regex as an options in the search, but haven't added that feature yet. But you can add your own custom search function. See https://github.com/javve/list.js/blob/master/test/test.search.js#L97

@javve javve closed this as completed Feb 24, 2016
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

No branches or pull requests

2 participants