$re = '/^([0-9]{3})-?([0-9]{3})-?([0-9]{3})-?([0-9]{3})?$/m';
$str = '009026405
01009556500
226-356-839
00829029200
008-018-454
009-513-213
00383951900
000147765000
96029000672
008-743-791
009568337
136759989000
009724967000
2RC0001624466
286169755000
201-947-430-0
241402504000
223651060000
';
$subst = "[$1.$2.$3.${4:+$4:000}]";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php