$re = '/(\b\d{8})(\d{6}Z)\b/';
$str = '20150624145707Z
20150603182904Z
20150421163629Z
20140529152951Z
20091015212450Z
20140428144528Z
20081009222929Z
20150817231245Z
20150420184902Z
20140428143953Z
20150315070002Z
20150315070003Z
20150212154444Z
20150527165706Z
19970205203358Z
20150413180400Z
20150924180348Z
20030823025726Z
20150423223718Z
20141022171412Z
20150412232614Z
20070505011754Z
20140428144155Z
20141231221928Z
20150305150408Z
20060103155521Z
20131114224409Z
20150910000720Z
20150831151016Z
';
$subst = "$1";
$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