Skip to content

Instantly share code, notes, and snippets.

@garenyondem
Last active October 18, 2018 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garenyondem/517d1f2db523822628e11b987c8f9c29 to your computer and use it in GitHub Desktop.
Save garenyondem/517d1f2db523822628e11b987c8f9c29 to your computer and use it in GitHub Desktop.
Convert Arabic or Persian numerals to Western numerals
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