use strict;
my $str = '1234as
12as32
09ppdj
ppdj09
12asd3
er123a
123ab2
2dgs23
123as2
asd12a
p23bgf
asdfdw
123432
123asd
ds321a
12asd1
1234aa
a321as
3asr33
V-127-DR 27-09-2017 t/m 26-10-2017 MEER INFO WWW.BELASTINGDIENST.NL
XX-99-99- asda sda
99-99-XX boekeing asdasdasd
99-XX-99 achrijving
XX-99-XX
deze matcht niet XX-XX-99 want het begint niet met een kenteken
99-XX-XX
99-XXX-9
9-XXX-99 dit is een omgschrijving van de belastingdienst
XX-999-X
X-999-XX
XXX-99-X';
my $regex = qr/^((([0-9]{3}(?![0-9]))|([a-z]{3}(?![a-z])))|(([0-9]{1,2})|([a-z]{1,2}))|-){6,}/imp;
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