I'm trying to extract some info from a website. The response I'm getting from the http request is
{"table_html": "\n
<div class='index-currency-table'>\n
<!--http://1000hz.github.io/bootstrap-validator/#validator-usage-->\n
<div class=\"row\">\n
<div class=\"col-xs-12\">\n
<table class=\"table--exchange table--exchange--responsive\">\n
<thead>\n
<tr>\n
<th scope=\"col\">Currency</th>\n
<th scope=\"col\">Nominal</th>\n
<th scope=\"col\">The bank buys</th>\n
<th scope=\"col\">The bank sells</th>\n
<th scope=\"col\">BNB</th>\n
</tr>\n
</thead>\n
<tbody>\n \n
<tr>\n
<td data-table-header=\"Currency\">\n
<a href=\"/en/rates-indexes/currency-rates/USD/\" target=\"_self\" title=\"United States Dollar\">
<span class=\"flag-icon flag-icon-us\"></span> USD
</a>\n
</td>\n
<td data-table-header=\"Nominal\">1</td>\n \n
<td data-table-header=\"The bank buys\">1.581200</td>\n
<td data-table-header=\"The bank sells\">1.646100</td>\n \n
<td data-table-header=\"BNB\">1.614390</td>\n
</tr>\n \n
</tbody>\n
</table>\n
</div>
<!--col-->\n
</div>
<!--row-->\n
</div>\n\n"}
I want to get the buy and sell rate values (1.581200, 1.646100). Having in mind that the HTML is represented as what would be the best approach here? For me regex appears to be the simplest solution however I don't think its the best. Is there a way to parse the string back to HTML or convert the whole thing to proper JSON?
var regex = /[\d|,|.\+]+/g;
var string = "result.table_html";
var matches = string.match(regex);