Skip to content

Instantly share code, notes, and snippets.

@yakovsh
Last active May 23, 2022 19:43
Show Gist options
  • Save yakovsh/345a71d841871cc3d375 to your computer and use it in GitHub Desktop.
Save yakovsh/345a71d841871cc3d375 to your computer and use it in GitHub Desktop.
Removing Vowels from Hebrew Unicode Text
/*
* One of the questions that recently came up is how to remove vowels from Hebrew characters in Unicode
* (or any other similar language). A quick look at Hebrew Unicode chart shows that the vowels are all
* located between 0x0591 (1425) and 0x05C7 (1479). With this and Javascript's charCodeAt function, it
* is trivial to strip them out with Javascript as follows
*
* Live demo is available here:
* https://jsfiddle.net/js0ge7gn/
*/
function stripVowels(rawString)
{
var newString = '';
for(j=0; j<rawString.length; j++) {
if(rawString.charCodeAt(j)<1425
|| rawString.charCodeAt(j)>1479)
{ newString = newString + rawString.charAt(j); }
}
return(newString);
}
/* @shimondoodkin suggested even a much shorter way to do this */
function stripVowels2(rawString) {
return rawString.replace(/[\u0591-\u05C7]/g,"")
}
@drjrodriguez
Copy link

I don't know why the code font didn't kick in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment