$re = '/overdraftlog-[0-9]{14}.[0-9]{3}(.log$|.log.sha$)/m';
$str = 'overdraft-transactions_2020-06-19_10_20200620020000.csv
overdraft-transactions_2020-06-19_10_20200620020000.csv.sha1
overdraft-transactions_2020-06-20_6_20200621020000.csv
overdraft-transactions_2020-06-20_6_20200621020000.csv.sha1
overdraft-transactions_2020-06-21_6_20200622020000.csv
overdraft-transactions_2020-06-21_6_20200622020000.csv.sha1
overdraft-transactions_2020-06-22_7_20200623020000.csv
overdraft-transactions_2020-06-22_7_20200623020000.csv.sha1
overdraft-transactions_2020-06-23_6_20200624020001.csv
overdraft-transactions_2020-06-23_6_20200624020001.csv.sha1
overdraft-application_2020-06-19_0_20200620020000.csv
overdraft-application_2020-06-19_0_20200620020000.csv.sha1
overdraft-application_2020-06-20_0_20200621020000.csv
overdraft-application_2020-06-20_0_20200621020000.csv.sha1
overdraft-application_2020-06-21_0_20200622020000.csv
overdraft-application_2020-06-21_0_20200622020000.csv.sha1
overdraft-application_2020-06-22_0_20200623020000.csv
overdraft-application_2020-06-22_0_20200623020000.csv.sha1
overdraft-application_2020-06-23_0_20200624020001.csv
overdraft-application_2020-06-23_0_20200624020001.csv.sha1
overdraftlog-20201005122521.748.log
overdraftlog-20201005122521.748.log.sha
overdraftlog-20201006030000.749.log
overdraftlog-20201006030000.749.log.sha';
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