Created
October 22, 2019 21:51
-
-
Save tanmancan/7c85c17c50390ecb0974586746e7428e to your computer and use it in GitHub Desktop.
Free search using .match()
This file contains hidden or 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
unmappedListings() { | |
return this.listings | |
.filter(listing => !listing.node.abbListingID) | |
.filter((listing) => { | |
if (this.search) { | |
const searchTerm = this.search.trim() | |
.toLowerCase() | |
.split(' ') | |
.join('|'); | |
const regex = new RegExp(`(${searchTerm})`, 'g'); | |
const isListing = listing.node.name.toLowerCase() | |
.match(regex); | |
const isPmsId = listing.node['Unit Code'].toLowerCase() | |
.match(regex); | |
return (isListing && isListing.length > 0) | |
|| (isPmsId && isPmsId.length > 0); | |
} | |
return true; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment