$re = '/^(?!version-[\d.]+$).*12\.3.*$/m';
$str = 'bugfix-ISSUE-123-some-details-version-12.3
ISSUE-1234-some-other-details-version-12.3
bugfix-12.3
bugfix2-12.3
12.3stuff
stu12.3ff
// match everything above, but don\'t match anything from below
master
version-12.3
version-3.21
some-other-branch
bugfix-3.21
test';
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