Last active
September 18, 2016 08:42
-
-
Save chengjianhua/1c751c5db6eb990642e44e4c20282da9 to your computer and use it in GitHub Desktop.
fuzzy search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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