пока не проверял:

$content = file(”textwithproxy.txt”);
$s = implode($content);
preg_match_all (”/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s*:\s*\d{1,5}/”, $s, $matches);
unlink(”proxyonly.txt”);
$fp = fopen(”proxyonly.txt”,”a+”);
foreach($matches[0] as $m)
{
$m = str_replace(” “,”",$m);
fwrite($fp,$m.”\n”);
}
fclose($fp);