Regular expressions. But from your examples, I'm not sure what you're looking for. Your first two examples have seven digits in the middle component of the numeric string; the third has only six.
$url =
ereg_replace('(([0-9])-([0-9])-([0-9]*))','',$url);
This will strip all sets of three numbers separated by hyphens.
1-2-3 will be stripped as well as 123-4566-6789,