$re = '/((?:(us\-)?repository(?(1)|nocdn)?|h(?:(1)|(3)|(5)|(p))\-(?(6)webs01\-s|repo(?(3)(sitory)?01|(?(4)sitory02|(?(5)sitory03|)))\-v))|repo(?:nocdn|us)\.wip|(?:nocdn|us)\-repository\.gtm|91-228-167-25\.ptr)\.eset\.com/mi';
$str = 'repository.eset.com
us-repository.eset.com
repositorynocdn.eset.com
hp-webs01-s.eset.com
h1-repo01-v.eset.com
h1-repository01-v.eset.com
h3-repository02-v.eset.com
h5-repository03-v.eset.com
91-228-167-25.ptr.eset.com
nocdn-repository.gtm.eset.com
us-repository.gtm.eset.com
reponocdn.wip.eset.com
reponocdn.wip.eset.com
reponocdn.wip.eset.com
repous.wip.eset.com
';
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