Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
javascript function to detcte the regex for string along with number

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  
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!