var a = "السلام عليكم"; //Arabic for Peace Be Upon You (Hello)
var h = a.replace(/(.)/g, function($1){
return ($1 == " ") ? $1 : "&#" + $1.charCodeAt() + ";";
});
The variable h now holds السلام عليكم
a.replace(/(.)/g, function($1){ if ($1 == " ") return " "; else return "&#" + $1.charCodeAt() + ";"; })
"السلام عليكم"
"السلام عليكم"
"السلام عليكم"
"السلام عليكم"
console.log("السلام عليكم".replace(/(.)/g, function($1){ if ($1 == " ") return " "; else return "&#" + $1.charCodeAt() + ";"; }));
No comments:
Post a Comment