Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:29:40+00:00 2026-06-10T11:29:40+00:00

I want to check if a number is Arabic , and replace all it’s

  • 0

I want to check if a number is Arabic , and replace all it’s digits to English so that I can do calculation on it . I’m trying this Function , but I don’t know what regular expression is suitable for it :

function enNumber(num)
{
for (var i=0;i<10;i++)
num=num.replace(*[regular expression]*,i);
return num;}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:29:42+00:00Added an answer on June 10, 2026 at 11:29 am

    Minimum solution for the question that was asked

    This should solve what you asked for:

    function fromArabicToASCII(arabic) {
      return arabic.replace(
        /[\u0660-\u0669\u06F0-\u06F9]/g,
        function(a) {
          return String.fromCharCode((a.charCodeAt(0)&15)+48);
        }
      );
    };
    

    General function for all known digits in Unicode class Nd (Number, Decimal Digit)

    The function below has support for Unicode class Nd (Number, Decimal Digit):
    Adlam, Ahom, Arabic-indic, Balinese, Bengali, Bhaiksuki, Brahmi, Chakma, Cham, Devanagari, Extended Arabic-indic, Fullwidth, Gujarati, Gurmukhi, Javanese, Kannada, Kayah Li, Khmer, Khudawadi, Lao, Lepcha, Limbu, Malayalam, Mathematical Bold, Mathematical Double-struck, Mathematical Monospace, Mathematical Sans-serif Bold, Mathematical Sans-serif, Meetei Mayek, Modi, Mongolian, Mro, Myanmar Shan, Myanmar Tai Laing, Myanmar, New Tai Lue, Newa, Nko, Ol Chiki, Oriya, Osmanya, Pahawh Hmong, Saurashtra, Sharada, Sinhala Lith, Sora Sompeng, Sundanese, Tai Tham Hora, Tai Tham Tham, Takri, Tamil, Telugu, Thai, Tibetan, Tirhuta, Vai, Warang Citi.

    There is no support for roman numbers and other non-decimal numbers, because they are not decimal.

    // This function takes an UTF16 encoded string as input,
    // and returns with all suported digits from Unicode
    // class 'Nd' (Number, Decimal Digit) replaced with their
    // equivalent ASCII digit.
    // Source : http://stackoverflow.com/a/12171250/36866
    // License: MIT
    // Author : some@domain.name
    // Note   : If you are going to use this code I would appreciate to
    //          get an email to some@domain.name. You don't have to but
    //          it would make me happier!
    var digitsToASCII=
      (function () {
        // Regexp that matches all supported digits.
        // Most Unicode digit classes have the zero digit at a codepoint
        // where the four least significant bits are ether zero or six.
        // The notable exception is the Math-class where several classes
        // have sequential codepoints. The information about the offset
        // is needed when decoding, and by using groups in the RexExp
        // no lookup is needed.
        var reDigit = new RegExp(
          '('+ // Offset 0
            '['+
              '\u0030-\u0039\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9'+
              '\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049'+
              '\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u19D0-\u19D9'+
              '\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9'+
              '\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9'+
              '\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59'+
              '\uABF0-\uABF9\uFF10-\uFF19'+
            ']'+
            '|\uD801[\uDCA0-\uDCA9]'+
            '|\uD804[\uDCF0-\uDCF9\uDDD0-\uDDD9\uDEF0-\uDEF9]'+
            '|\uD805['+
              '\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59'+
              '\uDEC0-\uDEC9\uDF30-\uDF39'+
            ']'+
            '|\uD806[\uDCE0-\uDCE9]|\uD807[\uDC50-\uDC59]'+
            '|\uD81A[\uDE60-\uDE69]|\uD81A[\uDF50-\uDF59]'+
            '|\uD83A[\uDD50-\uDD59]'+
          ')|('+ // Offset 6
            '['+
              '\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF'+
              '\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF'+
              '\u0D66-\u0D6F\u0DE6-\u0DEF\u1946-\u194F'+
            ']'+
            '|\uD804[\uDC66-\uDC6F\uDD36-\uDD3F]'+
          ')|('+ // Math
            '\uD835[\uDFCE-\uDFFF]'+
          ')',
          'g'
        );
    
        function replace(match, offset0, offset6, offsetMath) {
          // 'match' contains the whole match and can therefore have
          // a length longer than one character if surrogate pairs is used.
          // By getting the last character from 'match' the operation is simplified.
          var raw = match.charCodeAt( match.length - 1);
          var digit =
            offset0 ? raw & 0xF : // use 4 bits
            offset6 ? (raw -6) & 0xF : // subtract 6, use 4 bits
            offsetMath ? ((raw - 0xCE) & 0x3F) % 10 : // subtract CE, use 6 bits
            null;
    
          return String.fromCharCode(48 + digit); // Digit to ASCII
        }
    
        return function replaceDigits(input) {
          return input.replace(reDigit, replace);
        }
      })();
    

    Usage:

    myAsciiVariable = digitsToASCII( myForeignVariable );
    

    Module for node.js

    A function similar to this one is now available in a node.js module called unicodedigits. That function can translate from any supported digit to ASCII or any of the supported ranges.

    You can install it with npm install unicodedigits --save or find it on github.com/somec/unicodedigits

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a set number of String 's that I want to check
I want to check the number of characters I can insert in a text
A large number of clients want to check in with a server about once
I want to check if user input a positive integer number. 1 = true
I want to check if string doesn't have more than 5 numbers. I can
I have a bunch of numbers timestamps that I want to check against a
I want to check in a table table1 number of records with sno =
I want to check whether there is string starting from number and then optional
I have number of checkboxes and another checkbox for Select All I want to
I want to be able to check if I can edit a cell in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.