How can I convert Persian/Arabic numbers to English numbers with a simple function?
arabicNumbers = [\"١\", \"٢\", \"٣\", \"٤\", \"٥\", \"٦\", \"٧\", \"٨\",
If the string may contain both "Arabic" and "Persian" numbers then a one-line "replace" can do the jo as follows.
The Arabic and Persian numbers are converted to English equivalents. Other text remains unchanged.
Num= "۳٣۶٦۵any٥۵٤۶32٠۰"; // Output should be "33665any55453200"
Num = Num.replace(/[٠-٩]/g, d => "٠١٢٣٤٥٦٧٨٩".indexOf(d)).replace(/[۰-۹]/g, d => "۰۱۲۳۴۵۶۷۸۹".indexOf(d));
console.log(Num);