javaScript String Получите номера
var num = txt.replace(/[^0-9]/g,'');
Pudochu
var num = txt.replace(/[^0-9]/g,'');
function onlyNumbers(text){
return text.replace(/\D/g, "");
}
let string = "xxfdx25y93.34xxd73";
let res = string.replace(/\D/g, "");
console.log(res);
function retnum(str) {
var num = str.replace(/[^0-9]/g, '');
return parseInt(num,10);
}
thenum = "foo3bar5".match(/\d+/)[0] // "3"
var txt = "#div-name-1234-characteristic:561613213213";
var numb = txt.match(/\d/g);
numb = numb.join("");
alert (numb);
var thenum = thestring.replace( /^\D+/g, ''); // replace all leading non-digits with nothing
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>';
}