Created
March 29, 2020 15:15
-
-
Save valakhosravi/07142be44d353d22e7ec1257eb5a7e1d to your computer and use it in GitHub Desktop.
converting Persian or Arabic number to english numbers
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
| convertPersianNumberToEnglishNumbers(num) { | |
| const persianNumberList = [/۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g, /۰/g]; | |
| const englishNumberList = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']; | |
| persianNumberList.forEach((persianNumber, index) => { | |
| num = num.replace(persianNumber, englishNumberList[index]); | |
| }); | |
| return num; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment