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

79
Views
Regular expression to determine if phone number starts with a zero

How would I go about ensuring that numbers entered into a field starts with a 0? My initial question was suggesting that the company wants to force users to input 0 first, but I think an elegant solution would work better.

    function creationValidationNumber(dataValues, setErrors) {
     let testData:any = {};

     if ("numberPrime" in dataValues) testData.numberPrime = /^[a-zA-Z][0-9a-zA-Z 
     .,'-]*$/g.test(dataValues.numberPrime) ? "" : "Numbers must start with a 0";

     setErrors({ ...testData });

     return Object.values(testData).every((x) => x === "");
    }

I just don't know how to get the regular expression to test and throw an error if it doesn't start with 0

If anyone could please guide me on the right path.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You don't need regex for this. Just check if the first character is "0":

dataValues.numberPrime[0] == "0"
about 4 years ago · Juan Pablo Isaza Report

0

I don't know why you have a more complicated regex, all you need is:

/^0/
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!