Last active
October 18, 2018 14:10
-
-
Save garenyondem/517d1f2db523822628e11b987c8f9c29 to your computer and use it in GitHub Desktop.
Convert Arabic or Persian numerals to Western numerals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.toWesternNumerals = function () { | |
return this.replace(/[\u0660-\u0669]/g, (c) => { | |
return c.charCodeAt(0) - 0x0660; | |
}).replace(/[\u06f0-\u06f9]/g, (c) => { | |
return c.charCodeAt(0) - 0x06f0; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment