use strict;
my $str = '||10 980008530||000000-2209-165-EXE||Unverl. Kombischr._M5x25_UE_Nitronic_ISR||Nitronic60||3fach verpackt||10er Setverpackung||Reinigung und Verpackung nach VACOM Purity Class 4 / ZEISS 1000711||Bestellnr.K/Pos 1926779 1||Ihre Materialnr.: 000000000002209165-EXE||Charge: 0009114369 Gesamtmenge: 999 ST||Handling Unit: 10030337466 999 ST||20 980008530||000000-1234-999-EXE||Unverl. Kombischr._M5x25_UE_Nitronic_ISR||Nitronic60||3fach verpackt||10er Setverpackung||Reinigung und Verpackung nach VACOM Purity Class 4 / ZEISS 1000711||Bestellnr.K/Pos 1926779 1||Ihre Materialnr.: 000000000002209165-EXE||Charge: 0009114369 Gesamtmenge: 123456 ST||Handling Unit: 10030337466 999 ST||30 980008530||000000-8888-165-EXE||Unverl. Kombischr._M5x25_UE_Nitronic_ISR||Nitronic60||3fach verpackt||10er Setverpackung||Reinigung und Verpackung nach VACOM Purity Class 4 / ZEISS 1000711||Bestellnr.K/Pos 1926779 1||Ihre Materialnr.: 000000000002209165-EXE||Charge: 0009114369 Gesamtmenge: 999 ST||Charge: 000777777 Gesamtmenge: 22222 ST||Handling Unit: 10030337466 999 ST';
my $regex = qr/\|\|[0-9]+\s*[0-9]+\s*\|\|([0-9]{6}-[0-9]{4}-[0-9]{3}\S*)\|\|.*?Bestellnr\.K\/Pos\s*?([0-9]+)\s*?([0-9]+)\|\|.*?Charge:\s*?(\S+)\s*?Gesamtmenge:\s*?([0-9\.]+)\s*?ST/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