$re = '/(licence-[a-z]{2}-[a-z]{2})/m';
$str = 'company licences/patents
1 UX226, licence-pp-zz, licence-zz-pp, licence-xx-tt
2 VV3346E, SS345
3 licence-dd-zz
4 UT223, licence, ss
5 XBTYU, licence-tt-kk, licence-ss-tt
6 xc, zz
7 licence-xb-xz';
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