Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
How to replace Arabic number strings to English?

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 ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I did it with this method :

const p2e = s => s.replace(/[۰-۹]/g, d => '۰۱۲۳۴۵۶۷۸۹'.indexOf(d))

console.log(p2e('۲۱۱')); // outputs --> 211
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!