đoạn code bóc tách danh sách socks (ip/port) từ file nội dung sử dụng regex


$content = file_get_contents('myfile.htm');
//if(preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\:[0-9]{1,5}/', $content, $match)) {
if(preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3}):([0-9]{1,5})$/', $content, $match)) {
foreach ($match as $result) {
echo $result . "
\n";
}
} else {
echo "Not an IP address!
\n";
}
?>

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/jhdIgmX6SKw/13477