Skip to content

Instantly share code, notes, and snippets.

@gioiliop7
Created May 24, 2023 06:09
Show Gist options
  • Save gioiliop7/34ddd664712e0c35624731ebe1b1f4af to your computer and use it in GitHub Desktop.
Save gioiliop7/34ddd664712e0c35624731ebe1b1f4af to your computer and use it in GitHub Desktop.
Remove accents in greek string and make it capitalize
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