Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function toFarsiDigit(number) {
- const regex = /[0-9]/g
- let result = number.replace(regex, function (w) {
- return String.fromCharCode(w.charCodeAt(0) + 1728)
- })
- return result
- }
- function toEnglishDigit(number) {
- const regex = /[۰−۹]/g
- let result = number.replace(regex, function (w) {
- return String.fromCharCode(w.charCodeAt(0) - 1728)
- })
- return result
- }
- exports.toEnglishDigit = toEnglishDigit
- exports.toFarsiDigit = toFarsiDigit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement