$re = '/^\s*\'.*?\'\s*=>\s*(\'.*?\',?)$/m';
$str = ' \'cpt\' => \'application/mac-compactpro\',
\'cpt\' => \'application/x-compactpro\',
\'cpt\' => \'application/x-cpt\',
\'crl\' => \'application/pkcs-crl\',
\'crl\' => \'application/pkix-crl\',
\'crt\' => \'application/pkix-cert\',
\'crt\' => \'application/x-x509-ca-cert\',
\'crt\' => \'application/x-x509-user-cert\',
\'csh\' => \'application/x-csh\',
\'csh\' => \'text/x-script.csh\',
\'css\' => \'application/x-pointplus\',';
$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