Last active
October 25, 2022 11:42
-
-
Save blackestwhite/01a18aedb5380545b9f5ab9c3a90732b to your computer and use it in GitHub Desktop.
English to Persian, Persian to English digit conversion, JavaScript RegEx
This file contains hidden or 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 ToPersian = str => str.replace(/\d/g, idx => '۰۱۲۳۴۵۶۷۸۹'[idx]) | |
const ToEnglish = str => str.replace(/[۰-۹]/g, d => '۰۱۲۳۴۵۶۷۸۹'.indexOf(d)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment