Skip to content

Instantly share code, notes, and snippets.

@chengjianhua
Last active September 18, 2016 08:42
Show Gist options
  • Save chengjianhua/1c751c5db6eb990642e44e4c20282da9 to your computer and use it in GitHub Desktop.
Save chengjianhua/1c751c5db6eb990642e44e4c20282da9 to your computer and use it in GitHub Desktop.
fuzzy search
const data = this.data.slice();
const searchText = this.getSearchText();
const columnKeys = Object.keys(this.getColumns());
const reg = new RegExp(searchText.toLocaleLowerCase().split('').join('.*?'), ['g']);
const result = data.filter((value) => {
return columnKeys.some((key) => {
return reg.exec(String(value[key]).toLocaleLowerCase());
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment