Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^(?:(?:\+|00)33[\s.-]{0,3}(?:\(0\)[\s.-]{0,3})?|0)[1-9](?:(?:[\s.-]?\d{2}){4}|\d{2}(?:[\s.-]?\d{3}){2})$
/
gm

Description

Accept several kind of format, more or less usual. And refuse incorrect formats.

  • Prefix: 0033 / +33 / (0) / 0
  • Number: collapsed / group by 2 / group by 3
  • Separator: space / dot / dash
Submitted by RonanKER - 6 years ago