Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda