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

174
Views
Issue with PHP regex on differents type of phone numbers

I am actually stucked with a PHP Regex because I have to test different types of numbers.

I want to check if the first 2 numbers are in my array, but it can be possible that the first 0 is replaced by international numbers (+33 for France).

I don't have any idea how to test my following different types :

   +33 (0)6
   +33(0)6
   +33.6
   (+33).6
   (+33)6
   06

   +33 (0)7
   +33(0)7
   +33.7
   (+33).7
   (+33)7
   07

Any tips to do that ? Thanks

EDIT :

I tried this but not working wit parentesis :

^
   (?:(?:\+|00)33|0)    #indicatif
   \s*[6-7]             #first number (from 1 to 9)
   (?:[\s.-]*\d{2}){4}  #End of the phone number
$
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Try with:

$pattern = '/^(\+33( ?\(0\)|\.)|\(\+33\)\.?|0)[67][0-9]+$/';
$my_number = "+33.678910";
if(preg_match($pattern, $my_number)) // do something

If the number of digits has to be fixed, you may replace the last + with the number (or a range of numbers) that must follows the initial 6 (or 7).

For example:

/^(\+33( ?\(0\)|\.)|\(\+33\)\.?|0)[67][0-9]{5}$/
/^(\+33( ?\(0\)|\.)|\(\+33\)\.?|0)[67][0-9]{5,7}$/

The first regex means that the initial 6 (or 7) has to be followed exactly by 5 digits. The second is from 5 up to 7.

over 4 years ago · Santiago Trujillo Report

0

Ok I find out I guess.

Link : Regex

$pattern = "/(?:(?:(?:\+|00)33|0)|\(\+33\))(\s*|\(0\)|\s*\(0\)|\.)[6-7](?:[\s.-]*\d{2}){4}/";
over 4 years ago · Santiago Trujillo 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!