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

203
Vistas
check number equality in Javascript

I have numbers that will be coming from database with this format "+2349091736209" and I want to compare each number with a number I get from user contacts list. The value of phone numbers I get from the contacts is sometimes in this format "0909 173 6209" with spaces, while sometime like this "0909-173-6209". I need help on how to compare the db value with this variants and get if its a match. Thanks.

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

0

Sounds like a good use for regex.

dbNumber.replace(/\D/g, '') === contactsNumber.replace(/\D/g, '')

This takes the string and replaces any non-number information with an empty string. You can find this and more at one of the many Javascript regex playgrounds: https://regexlearn.com/cheatsheet

about 4 years ago · Juan Pablo Isaza Denunciar

0

phone_number.replace(/,/g, ""); phone_number.replace(/,/g, "-"); gives you the phone number without spaces or -. So you can compare.

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