Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^((00|\+)[0-9]{2,5}|0)[1-9][0-9]{8,9}$
/
gm

Description

It accepts phone numbers of the form 0XX XXX XX XX (stylized here, it doesn't really accept spaces). Also, it can detect the international area code (e.g. +41 OR 0041 for Switzerland). It's not a good idea to rely on the groups (because they do not work for this reason. At ALL.

Submitted by Adowrath - 9 years ago