Extract only numbers with one decimal point from String
by Faisal Khan Janjua
HTML
<p>a.bc1$%2@3c def74,56.7/h#ij\|879</p>
JavaScript
let mystring = $('p').text();
let valInCol = mystring.replace(/[^0-9.]/g, "");
var aftrDecimal = valInCol.lastIndexOf('.');
var beforeDecimals = valInCol.substring(0, aftrDecimal).replace(/\./g, '');
valInCol = beforeDecimals + valInCol.substring(aftrDecimal);
var htmltxt = '';
htmltxt += 'Decimal Position > '+aftrDecimal+'<br>';
htmltxt += 'Chars Before Decimals > '+beforeDecimals+'<br>';
htmltxt += 'Chars After Decimal > '+valInCol.substring(aftrDecimal)+'<br>';
htmltxt += 'Result > '+valInCol+'<br>';
$('body').append(htmltxt + "<br>");
console.log(valInCol);