remove Niqqud from string in javascript

左心房为你撑大大i 提交于 2019-12-20 02:41:29

问题


I have the exact problem described here:

removing Hebrew "niqqud" using r

Have been struggling to remove niqqud ( diacritical signs used to represent vowels or distinguish between alternative pronunciations of letters of the Hebrew alphabet). I have for instance this variable: sample1 <- "הֻסְמַק"

And i cannot find effective way to remove the signs below the letters.

But in my case i have to do this in javascript.

Based of UTF-8 values table described here, I have tried this regex without success.


回答1:


Just a slight problem with your regex. Try the following:

const input = "הֻסְמַק";
console.log(input)
console.log(input.replace(/[\u0591-\u05C7]/g, ''));

/*
$ node index.js
הֻסְמַק
הסמק
*/


来源:https://stackoverflow.com/questions/37716995/remove-niqqud-from-string-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!