With the help of http://www.regexr.com/ I created this preg_replace:
preg_replace("/\+[\d]{2}|\(0\)|\(|\)|\s/","",$number);
which changes any of these
+27123456789
+27 12 345 6789
(+27)123456789
(+27) 12 345 6789
+27 (0) 12 345 6789
+27(0)123456789
012 345 6789
0123456789
into 0123456789
(South African phone number format)
However, it doesn't change these two and no matter how I set it up, it doesn't want to work:
27 (0) 12 345 6789
27(0)123456789
How can I change the regex match so that it works with those as well?