<font color="green">+4,13</font>%
I know that I shouldn’t use regular expressions for that, but that’s a single case where my only html is that so…
how can I get “4,13” from the string above?
EDIT
Context:
I am sorting a table via jQuery TableSorter. A column contains that html-formatted data and I can’t change it. The custom parser I’m writing has a format function, which I currently use for managing currency, percentages and so on…
Now, I want to check, with a regex, if the string that comes to me is a string.
format: function(s) {
console.log(s);
var stripped = s.replace("<font>","")
.replace("</font>", "");
return jQuery.tablesorter.formatFloat(stripped);
}
This should work for your specific example –
Working demo – http://jsfiddle.net/ipr101/LHBp7/