I have this code for checking if it's a string please use some regex to extract only numbers, but in some cases i do have this:
Column1 Column2
($75.00) $0.00 PayPal Email Declined
var intVal = function(i) {
console.log(i);
return typeof i === 'string' ?
i.replace(/[\$,]/g, '') * 1 :
typeof i === 'number' ?
i : 0;
};
what regex needs to modify so i get the numbers values only
Update #1
Because i am doing datatables calculation in tfoot, i am using this code
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api();
var intVal = function ( i ) {
return typeof i === 'string' ? i.replace(/[^0-9]/g, '') * 1 : typeof i === 'number' ? i : 0;
};
ColumnThreeTotal = api
.column(3, {page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 3 ).footer() ).html(
'$'+ColumnThreeTotal
);
it has two problems, first it is showing of all rows instead of the current page, and second the results are coming as:
$1.000092378555231e+74