Created
September 12, 2017 20:38
-
-
Save danilat/3d34ea7b53fec0114a5a7f173374e204 to your computer and use it in GitHub Desktop.
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
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