Sorry for the noob question.
var regex = ??
var a = '<span class="star" id="1.00"></span>';
var number = a.match(regex);
How can I get the 1.00 using regex?
Thanks for the help..
Sorry for the noob question.
var regex = ??
var a = '<span class="star" id="1.00"></span>';
var number = a.match(regex);
How can I get the 1.00 using regex?
Thanks for the help..
Forexample:
var regex = /[0-9\.]+/;
var a = '<span class="star" id="1.00"></span>';
var number = a.match(regex);
alert(number);
5 if input text is <span class="star5" id="1.00"></span>/id\="(\d+(\.\d+)?)"/i below, it takes eg. <div class=xy id="1.00">, etc. He has a string without bobo attribute, wioth no additional numbers.IMHO using regex wont solve your problem, you should first craete an html element from the string and then get the id.
var s = '<span class="star" id="1.00"></span>';
var div = document.createElement('div');
div.innerHTML = s;
var element = div.firstChild;
console.log(element.getAttribute("id"))
output:
1.00