Created
September 7, 2020 18:55
-
-
Save jucemar-dimon/403ba811e549379be41838fb38b1297b to your computer and use it in GitHub Desktop.
Function to Filter array comparing strings ignoring special caracters
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 handleSearch = () => { | |
const formatedQuery = query | |
.toLowerCase() | |
.trim() | |
.normalize('NFD') | |
.replace(/[\u0300-\u036f]/g, ''); | |
const resultsTemp = clientes.filter(cliente => { | |
const formatedString = cliente.nome | |
.toLowerCase() | |
.trim() | |
.normalize('NFD') | |
.replace(/[\u0300-\u036f]/g, ''); | |
if (formatedString.includes(formatedQuery)) { | |
return true; | |
} | |
return false; | |
}); | |
return resultsTemp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment