$re = '/commit[\s\S]+?(?=commit [a-z0-9]+|$)/';
$str = 'commit 7200304f2e965e348dfa362a4adf80e4e0a3d621 (HEAD -> master, tag: v0.5.0.1, origin/master, origin/HEAD)
Author: Jonathan Dance <jd@wuputah.com>
Date: Mon May 21 11:02:39 2018 -0700
0.5.0.1
commit 7314c4a5f5c7502babe45fdd98e65c7210fbf92b
Author: Jonathan Dance <jd@wuputah.com>
Date: Mon May 21 11:01:31 2018 -0700
add task to build with chmod -R beforehand
fixes #129
commit 7314c4a5f5c7502babe45fdd98e65c7210fbf92b
Author: Jonathan Dance <jd@wuputah.com>
Date: Mon May 21 11:01:31 2018 -0700
add task to build with chmod -R beforehand
fixes #129';
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