3
Well I have the following code:
var tempo = "Rolling in 8.31...";
What I want is from the string above, leave only the number 8, so that var time, stay as follows:
var tempo = "8";
How can I do that?
Thank you.
@EDIT:
Current Code:
setInterval(function(){
var tempo = document.getElementById("banner");
var match = tempo.match(/[^\d](\d+)/);
var nr = match && match[1];
console.log(nr);
}, 1000);
You always have the same text
Rolling in
? or the text may vary? you can give more examples?– Sergio
The text, is always the same, the only thing that can vary is 8.31, I wanted everything to disappear and only to be 8. It can be for example 10.20, 15.23 etc... That is, I intend to remove the decimals and the remaining characters. And leave only the main number
– Gonçalo