Created
May 24, 2023 06:09
-
-
Save gioiliop7/34ddd664712e0c35624731ebe1b1f4af to your computer and use it in GitHub Desktop.
Remove accents in greek string and make it capitalize
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
export function removeAccents(str) { | |
const upperCaseSeriousString = str.toUpperCase(); | |
const greekLetters = { | |
Ά: "Α", | |
Έ: "Ε", | |
Ή: "Η", | |
Ί: "Ι", | |
Ϊ: "Ι", | |
Ό: "Ο", | |
Ύ: "Υ", | |
Ϋ: "Υ", | |
Ώ: "Ω", | |
}; | |
const regex = new RegExp("[" + Object.keys(greekLetters).join("") + "]", "g"); | |
return upperCaseSeriousString.replace(regex, function (match) { | |
return greekLetters[match]; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment