Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda