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

144
Vistas
Remove multiple characters from a string

I have a string like this: "22 - 11 - 33".

I would like to remove all the dashes '-' and all the spaces to return a string like this "221133".

I know there is a replace() method but as far as I know it only removes one thing passed into it. I would like to remove more than one character type.

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

0

"22 - 11 - 33".replace(/[^0-9]/g, ''); should work

about 4 years ago · Juan Pablo Isaza Denunciar

0

Use Regex replace for that:

console.log(
  "22 - 11 - 33".replace(/[^\d]/g, '')
);


[^\d] - replace anything that is not number
\d - matches numbers groups, similar to [0-9]
/g - replace all matches

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