Skip to content

Instantly share code, notes, and snippets.

@danilat
Created September 12, 2017 20:38
Show Gist options
  • Save danilat/3d34ea7b53fec0114a5a7f173374e204 to your computer and use it in GitHub Desktop.
Save danilat/3d34ea7b53fec0114a5a7f173374e204 to your computer and use it in GitHub Desktop.
class Matcher {
constructor(){
this.FROM = "ÃÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛ";
this.TO = "AAAAAEEEEIIIIOOOOUUUU";
}
hasTheTerm(text, term) {
if(text){
text = this.normalize(text.toUpperCase());
term = this.normalize(term.toUpperCase());
return (text.indexOf(term)>-1)
}
}
normalize(a_string){
this.FROM.split("").forEach((change_from, index) => {
const change_to = this.TO[index];
a_string = a_string.replace(change_from, change_to)
});
return a_string;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment