Skip to content

Instantly share code, notes, and snippets.

@jucemar-dimon
Created September 7, 2020 18:55
Show Gist options
  • Save jucemar-dimon/403ba811e549379be41838fb38b1297b to your computer and use it in GitHub Desktop.
Save jucemar-dimon/403ba811e549379be41838fb38b1297b to your computer and use it in GitHub Desktop.
Function to Filter array comparing strings ignoring special caracters
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