use strict;
my $str = 'Peie
71,176,953
T-re
71,173,557
5-Mts
41,653,495
45678
Sia
36,136,829
36,100,829
78,684,45
4-Diepi
120,829
uteCra
36,100
Oct2018
71,45,78
22 Apr2024
It should not match above.
66456,56,6
9-inches
789,879,89
2-Mts';
my $regex = qr/# The pattern should match twice or more.
(?:
# Begin of line.
^
# But not one of these lines:
(?!(?:4-Diepi|5-Mts|.*\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b.*)$)
# Digits and then any chars not beeing line ending, followed by a new line or end of line.
\d+[^\r\n]*(\R|$)
){2,}/mxp;
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