Skip to content

Instantly share code, notes, and snippets.

@ahmadidev
Created December 15, 2015 11:19
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 ahmadidev/4e3e53a7101dca1a5188 to your computer and use it in GitHub Desktop.
Save ahmadidev/4e3e53a7101dca1a5188 to your computer and use it in GitHub Desktop.
Replacing English numbers with Persian characters
var persianNumbers = [ '۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹' ];
var getPersianNumbers = function(str) {
return ('' + str).replace(/(\d)/g, function(x) { return persianNumbers[x]; });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment