function justNumbers(string) {
var numsStr = string.replace(/[^0-9]/g, '');
return parseInt(numsStr);
}
var input = "Rs. 6,67,000";
var number = justNumbers(input);
console.log(number); // 667000
Run code snippet
thenum = "foo3bar5".match(/d+/)[0] // "3"
str = "hello123!"
str.match(/(d+)/)[1] //Best way to find first matching number in string ;)
// Html: <span id="foo">280ms</span>
var text = $('#foo').text();
var number = parseInt(text, 10);
alert(number);
// parseInt('ms120'.replace(/[^0-9.]/g, ''), 10);
const num = 123; //> type number 123
const str = num.toString(); //> type string "123"