Just Numbers

Discussion in 'C#' started by moiseszaragoza, Sep 29, 2010.

  1. #1
    I was wondering if any one has a function that removes all nun Number characters from a string that would work on JScript



    Thanks for all the help
     
    moiseszaragoza, Sep 29, 2010 IP
  2. DennisXHopper

    DennisXHopper Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try the following:
    phone = +phone.replace(/\D/g,'');
     
    DennisXHopper, Sep 29, 2010 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    
    function toNumber(str) {
         return str.replace(/[^0-9]+?/g,"");
    }
    
    Code (markup):
     
    camjohnson95, Sep 30, 2010 IP