1

I need to create something like ... .replace(/\d+/g, ... but not for Latin digits, for Persian digits.
Numbers are: ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۰

I tought I can use something like ... .replace(/۱|۲|۳|۴|۵|۶|۷|۸|۹|۰/g, ..., but of course, it's not the same.

Mehdi Hoseini
  • 407
  • 1
  • 4
  • 12

1 Answers1

0

JavaScript doesn't have a shortcut for non-ASCII digits, so your approach is in the right spirit - you'd better use a character class for this, though:

/[۱۲۳۴۵۶۷۸۹۰]+/

or

/[۱-۰]+/
Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561