const converter = (text) => text.replace(/[٠-٩۰-۹]/g,a=>a.charCodeAt(0)&15);
console.log(converter("۳٣۶٦۵any٥۵٤۶32٠۰"));
// Output: "33665any55453200"
Last active
August 12, 2022 12:08
-
-
Save sajaddp/cfde6e99a26b6177fa353d4a597f7230 to your computer and use it in GitHub Desktop.
Convert Persian and Arabic digits of a string to English using JavaScript
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
const converter = (text) => text.replace(/[٠-٩۰-۹]/g,a=>a.charCodeAt(0)&15); | |
console.log(converter("۳٣۶٦۵any٥۵٤۶32٠۰")); | |
// Output: "33665any55453200" | |
//[Reference](https://stackoverflow.com/a/63133882/6390834) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment