I replace English number strings to Persian with a function like this :
const e2p = (s) => s.replace(/\d/g, (d) => '۰۱۲۳۴۵۶۷۸۹'[d]);
e2p("211") // --> output is ۲۱۱
Now I want to do the opposite by changing arabic string numbers to english .
I tried this method but it didn't work :
const p2e = s => s.replace(/\d/g, d => '0123456789'[d]);
console.log(p2e('۲۱۱')); // outputs --> ۲۱۱
How can I do this in javascript ?