use strict;
my $str = '1
EA
2.00 2814-212-D003 0.00 0.00
LONG JACK PAD
Drawing: OPT
Due: 05/19/2023 Requester: NMB
Order: 2843HR-213-703 Seq No: 9002
2
EA
2.00 2814-212-D003 0.00 0.00
LONG JACK PAD
Drawing: OPT
Due: 05/19/2023 Requester: NMB
Order: 2843HR-214-703 Seq No: 9002
3
EA
2.00 2814-212-D004 0.00 0.00
SHORT JACK PAD
Drawing: OPT
Due: 05/19/2023 Requester: NMB
Order: 2843HR-213-703 Seq No: 9003
4
EA
2.00 2814-212-D004 0.00 0.00
SHORT JACK PAD
Drawing: OPT
Due: 05/19/2023 Requester: NMB
Order: 2843HR-214-703 Seq No: 9003';
my $regex = qr/^(?<index>\d)\nEA\n\s(?<quantity>[0-9\.]+)\s(?<partNumber>[0-9A-Z-]+)\s(?<unknonw1>[0-9\.]+)\s(?<unknonw2>[0-9\.]+)\n(?<partName>[A-Z\s]+)\nDrawing\:\s(?<drawing>[A-Z]+)\nDue\:\s(?<date>[0-9]+\/[0-9]+\/[0-9]+)\sRequester\:\s(?<requester>[A-Z]+)\nOrder\:\s(?<order>[0-9A-Z-]+)\sSeq\sNo\:\s(?<sequence>[0-9]+)$/mp;
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