use strict;
my $str = 'Device:REVEAL LINQ LNQ11 Serial Number:RLA087267G Date of Visit:03-Jul-2019 08:10:51
Gerät:Viva Quad XT CRT-D DTBA2QQ Seriennummer:BLG613658S Untersuchungsdatum:27-Apr-2018 12:34:06
ICD-Modell: Marquis VR 7230 Seriennummer: PKD616419S Untersuchungsdatum:12, Mai 2015
ICD-Model: Marquis VR 7230 Serial Number: PKD616419S Untersuchungsdatum:12, Mai 2015
Pacemaker Model: Medtronic Adapta ADSR01 Serial Number: NWM851790 Date of Visit: 12/08/17
Schrittmachermodell: Medtronic Adapta ADVDD01 Seriennummer: NWG618042 Nachsorgedatum: 05.12.1';
my $regex = qr/(.*Device:\s*(.*?)\s*Serial Number.*)|(.*Gerät:\s*(.*?)\s*Seriennummer.*)|(.*ICD-Model:\s*(.*?)\s*Serial Number:.*)|(.*ICD-Modell:\s*(.*?)\s*Seriennummer.*)|(.*Pacemaker Model:\s*(.*?)\s*Serial Number.*)|(.*Schrittmachermodell:\s*(.*?)\s*Seriennummer:.*)/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