$re = '/http:\/\/(?<domain>[^\/\n]+)\/[^\?\n]+[?](?<params>[^\n]+)/';
$str = 'http://site.com/index.php?id=1
http://site.com/index.php?id=2
http://site.com/index.php?id=3
http://site.com/index.php?id=1¶m=a
http://site.com/index.php?id=1¶m=b&year=2015
http://site2.com/index.php?id=3
http://site2.com/index.php?id=4
http://site2.com/index.php?id=5
http://site2.com/index.php?id=1¶m=x
http://site2.com/index.php?id=1¶m=y
http://site2.com/index.php?id=3¶m=z';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 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