Fix Arabic Character For Persion

_strReplaceForArabic(str){
if(str != null){
let regex = /ي/ig;
let level1 = str.replace(regex, 'ی');

regex = /ك/ig;
let level2 = level1.replace(regex, 'ی');

regex = /ة/ig;
let level3 = level2.replace(regex, 'ی');

return level3;
}else{
return str;
}
}

Remove all special characters with RegExp

_strReplaceForArabic(str){
if(str != null){
let regex = /ي/ig;
let level1 = str.replace( regex, 'ی');

regex = /ك/ig;
let level2 = level1.replace( regex, 'ی');

regex = /ة/ig;
let level3 = level2.replace( regex, 'ی');

regex = /[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi;
let level4 = level3.replace( regex, '');

let level5 = level4.trim();

return level5;
}else{
return str;
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store