javascript string get numbers
var num = txt.replace(/[^0-9]/g,'');
javascript string get numbers
var num = txt.replace(/[^0-9]/g,'');
javascript string get numbers
let string = "xxfdx25y93.34xxd73";
let res = string.replace(/\D/g, "");
console.log(res);
javascript string get numbers
function retnum(str) {
var num = str.replace(/[^0-9]/g, '');
return parseInt(num,10);
}
javascript string get numbers
thenum = "foo3bar5".match(/\d+/)[0] // "3"
javascript string get numbers
var txt = "#div-name-1234-characteristic:561613213213";
var numb = txt.match(/\d/g);
numb = numb.join("");
alert (numb);
javascript string get numbers
var thenum = thestring.replace( /^\D+/g, ''); // replace all leading non-digits with nothing
javascript string get numbers
function getre(str, num) {
if(str === num) return 'nice try';
var res = [/^\D+/g,/\D+$/g,/^\D+|\D+$/g,/\D+/g,/\D.*/g, /.*\D/g,/^\D+|\D.*$/g,/.*\D(?=\d)|\D+$/g];
for(var i = 0; i < res.length; i++)
if(str.replace(res[i], '') === num)
return 'num = str.replace(/' + res[i].source + '/g, "")';
return 'no idea';
};
function update() {
$ = function(x) { return document.getElementById(x) };
var re = getre($('str').value, $('num').value);
$('re').innerHTML = 'Numex speaks: <code>' + re + '</code>';
}
javascript string get numbers
function onlyNumbers(text){
return text.replace(/\D/g, "");
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us