I use the following utility method to convert Persian and Arabic digits to English using regex
:
convertNumbers2English: function (string) {
return string.replace(/[٠١٢٣٤٥٦٧٨٩]/g, function (c) {
return c.charCodeAt(0) - 1632;
}).replace(/[۰۱۲۳۴۵۶۷۸۹]/g, function (c) {
return c.charCodeAt(0) - 1776;
});
}