I need to get numbers only (strip commas and currency symbol) from a value in an id called "price". I have the following:
function() {
var element = document.querySelector('*[id^="price"]');
var price = element.innerHTML.match(/\d*\.\d*/)[0];
return price;
}
This works fine of the value is something like "£10.50". But if my value has a comma such as "£2,050.00" it returns "050.00".
How do i get just numbers and replace any currency symbols and commas?