First of all please try to learn how about regex. Here is the great site. If you do not learn yourself, then you have to beg for help to others like this one every time. It is always better to provide your example that you have done so far, so that the SO community can continue from there to guide you.
Here is a hedious regex:
preg_match("/^([a-z0-9]{4,6})([a-z0-9]{3})([a-z0-9]{3})(?:([a-z0-9]{4,5})(\\3)([a-z0-9]{3}))?$/i", $numbers, $m);
print_r($m);
Use this site, and paste the regex over there to get explanation of it.