Regex: South African Phone number

Sometimes it is tough finding South African specific regular expressions.

Here is a quick and dirty solution for South African Cell and Landline numbers:

Regex:

^(0|[+27]{3})[0-9]{2}-?[0-9]{3}-?[0-9]{4}$

Supported Formats:

XXX-XXX-XXXX

+27XX-XXX-XXXX

XXXXXXXXXX

XXXXXX

XXX-XXXX

Matches:

+2782-610-5069
+27826105069
0826105069
082-610-5069
0116901069
011-691-5069
+2711-190-5069

Note – If you want to also match on landlines without the city prefix eg 678-7890 or 6788778, this will do the trick:

^((0|[+27]{3})[0-9]{2})?-?[0-9]{3}-?[0-9]{4}$

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s