Regular Expression For Arabic Language

后端 未结 3 784
暗喜
暗喜 2020-11-27 16:39

I want to write a regular expression that matches each word in a sentence:

My regular expression:\"\\b(\\w+)\\b\"

Result:

3条回答
  •  春和景丽
    2020-11-27 17:07

    You can do it with function to translate Aracbic Characters list, Its very simple to do.

    As Like :

    function (regexStr) {
       regexStr = replace(regexStr,"ۿ","\u0600");
       regexStr = replace(regexStr,"؀","\u06FF");
    
       return regexStr;
    }
    

    Or in another idea replacing [alf] and [ya] to see your text direction correctly

    var regexStr = "/[[alf]-[ya]]/";
    
     function (regexStr) {
       regexStr = replace(regexStr,"[alf]","\u0600");
       regexStr = replace(regexStr,"[ya]","\u06FF");
    
       return regexStr;
    }
    

提交回复
热议问题