-1

How can I extract numeric part from value stored in another variable ?

For example:

 var a=some_string ;

Now I want to extract numeric value of a and store it in another variable .

stackoverflowuser
  • 252
  • 1
  • 3
  • 12

1 Answers1

1

Example--

var a='kjh56SS';
var b='';
for(var i=0;i<a.length;i++){
    if(!isNaN(a.charAt(i))){
         b=b+a.charAt(i);
    }
}
alert(b);

Demo-- http://jsfiddle.net/mwkn4c8t/

RahulB
  • 2,070
  • 1
  • 18
  • 26
  • 1
    Solution looks dumb and inefficient without regex !! You can go for regex answers if you want!! – RahulB Nov 12 '14 at 10:11