如何从C#中的给定阿拉伯字符串中删除TASHKEEL / HARAKAT

时间:2017-03-27 15:58:19

标签: c# .net .net-4.6.2

我想从任何给定的阿拉伯字符串中删除以下TASHKEEL / HARAKAT而不删除字母

我该怎么做?

C#.net 4.6.2

enter image description here

2 个答案:

答案 0 :(得分:3)

取自其他问题的示例字符串

string str = "الْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ";

// to be replaced characters
char[] tashkeel = new char[]{'ِ', 'ُ', 'ٓ', 'ٰ', 'ْ', 'ٌ', 'ٍ', 'ً', 'ّ', 'َ'};

// doing the replacement
foreach(char c in tashkeel)
    str = str.Replace(c.ToString(),"");

MessageBox.Show(str);

答案 1 :(得分:1)

试试这个

      str= str.Replace("\u064b", "");
        str= str.Replace("\u064f", "");
        str= str.Replace("\u064c", "");
        str= str.Replace("\u0652", "");
        str= str.Replace("\u064d", "");
        str= str.Replace("\u0650", "");
        str= str.Replace("\u0651", "");
        str= str.Replace("\u064e", "");