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

291
Vistas
Regex to replace commas between a positive number and negative number
        global=global.toString().replace(/(\d+),,,(?=\d)/g, '$1,.');
  1. I am replacing the commas here. I need to replace the commas in between a positive and the second a negative number.

  2. I am replacing the commas here. I need to replace the commas in between a positive and the second a positive or negative number.

How do I do both of these?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

For example

const global = '1,-1,2,4,-2';
global.replace(/(-?\d+),(?=-?\d+)/g, '$1,.');

will output

'1,.-1,.2,.4,.-2'

So, you just need to add -? in your expression to indicate it is possible to be positive or negative.

about 4 years ago · Juan Pablo Isaza Denunciar
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