use strict;
my $str = 'Code: 210 - Test 1 - Distribution
267745 Vis - Branch Deposit 3/10/2021 2,000.00
468040 v- Branch Deposit 2/10/2021 1,700.00
586075 Visa 3/3/2021 555.48
502490 Vis 3/4/2021 1,835.51
403195 Vis 3/4/2021 2,033.56
500230 Vis 3/4/2021 651.29
Code: 210 - Test - Distribution 8,775.84
Code: 230 - Greenville - Distribution
853955 Clearing 2/1/2021 77.50';
my $regex = qr/(?<=Code:).*Distribution\s([\d.,]+)(?=\n)/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