Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(?:(?:(?:(?:\+|00)\d{2})?[ -]?(?:(?:\(0?\d{2}\))|(?:0?\d{2})))?[ -]?(?:\d{3}[- ]?\d{2}[- ]?\d{2}|\d{2}[- ]?\d{2}[- ]?\d{3}|\d{7})|(?:(?:(?:\+|00)\d{2})?[ -]?\d{3}[ -]?\d{3}[ -]?\d{3}))$
/

Description

Validates following phone number schemes: 1234567 123-45-67 12-34-578 711234567 0711234567 71 123-45-78 71-123-45-78 071 123-45-78 071-123-45-78 +48711234567 +48 71 123-45-78 0048711234578 0048 71 123-45-78 (71) 123-45-78 (071) 123-45-78 123-456-789 0048123456789 +48123456789 0048 123-456-789 +48 123-456-789 etc. Dashes can be substituted for spaces No capture.

Submitted by Forseti - 9 years ago