$re = '/^(\w\.)(\s\w+\sJ?r?\.?)*(\w+[\sI\,\sJSr.]{0,5})$/m';
$str = 'H. Graham Motion
T. James Kelly
J. Palacios Moli
A. Chadwick Box
H. Graham Motion III
T. James Kelly, Jr.
H. Graham Motion II
V. Barboza Jr.';
$subst = "\1 \3";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
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