use strict;
my $str = 'AvAnalysisTill20Kepoch_onlyW.png
Program.30_07_2017_14_03_31.1.json
Program.30_07_2017_14_03_31.1.mat
Program.30_07_2017_14_03_31.10002.mat
Program.30_07_2017_14_03_31.10005.mat
Program.30_07_2017_14_03_31.10005.av.mat
Program.30_07_2017_14_03_31.10005.mat
Program.30_07_2017_14_03_31.10008.mat
Program.30_07_2017_14_03_31.10011.mat
Program.30_07_2017_14_03_31.10014.mat
Program.30_07_2017_14_03_31.10017.mat
Program.30_07_2017_14_03_31.1002.mat
Program.30_07_2017_14_03_31.10020.mat
Program.30_07_2017_14_03_31.10023.mat
Program.30_07_2017_14_03_31.10026.mat
Program.30_07_2017_14_03_31.10029.mat
Program.30_07_2017_14_03_31.10032.mat
Program.30_07_2017_14_03_31.10035.mat
Program.30_07_2017_14_03_31.10038.mat
Program.30_07_2017_14_03_31.10041.mat
Program.30_07_2017_14_03_31.10044.mat
Program.30_07_2017_14_03_31.10047.mat
Program.30_07_2017_14_03_31.1005.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19950.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19953.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19956.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19959.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19962.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19965.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19968.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19971.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19974.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19977.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19980.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19983.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19986.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19989.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19992.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19995.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.19998.mat
UBUNTU_30x300w30r3E-2.02_08_2017_12_09_36.20000.mat
';
my $regex = qr/[\w\+\-]+\.\w+\.(?<EPOCH>\d+)(?<AV>\.av)?\.mat/p;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html