Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!