$re = '/name[0-9]+\:([^:]{0,30})/i';
$str = '28:announce39://torrent.ubuntu.com:6969/announce13:announce-listll39://torrent.ubuntu.com:6969/announceel44://ipv6.torrent.ubuntu.com:6969/announceee7:comment29:Ubuntu CD releases.ubuntu.com13:creation datei1382003607e4:infod6:lengthi925892608e4:name30:ubuntu-13.10-desktop-amd64.iso12:piece lengthi524288e6:pieces35320:I½ÊŒÞJÕ`9';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0);
// Print the entire match result
var_dump($matches);
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