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

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

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

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 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