Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda