Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

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

Description

*Optional Country code (+xxx|00xxx) *Zone code with optional parenthesis for leading zero. 2-5 digit zone code, with different spacing. *Optional hyphen (optional spaces before and|or after) *Max service number 7 digits. different groups with optional spaces, 2-5 digits per group

Submitted by Mattias - 8 years ago