use strict;
my $str = 'letter_type|date|salutation|Title|First_name|Last_name|Street|House_number|Post_code|Country_code|City|Player_number|credit_account_no|credit_bank_code|debit_account_no|debit_bank_code|Wager_amount|steuer_nr_1|steuer_nr_2|credit_BIC|credit_IBAN|debit_BIC|debit_IBAN|Mandatsreferenz|Einzugstermine|SubscriptionDetails
^DA1A|23.08.2018|Herr||Max|Muster|Musterstr.|22|11111|DEU|Musterhausen|100026114|||||55,00|||eineBic|DE99999999999999999999|eineBic|DE99999999999999999999|REF06jddm4urgqki-02|
|
IBAN: DE99999999999999999999$BIC: eineBic$Spielauftrag: 3000030190$Veranstaltung: Samstag$Spielart: GlücksSpirale$1.Teilnahme: 06.01.2018$Letzte Teilnahme: 29.12.2018$Losnummer: 2290227$Superzahl: 7$Spiel77: Nein$SUPER6: Nein$Anteilssystem: 1/5$%
|
IBAN: DE99999999999999999999$BIC: eineBic$Spielauftrag: 3000030191$Veranstaltung: Samstag$Spielart: GlücksSpirale$1.Teilnahme: 06.01.2018$Letzte Teilnahme: 29.12.2018$Losnummer: 2290228$Superzahl: 7$Spiel77: Nein$SUPER6: Nein$Anteilssystem: 1/5$%
^DA1A|23.08.2018|Herr||Max|Muster|Musterstr.|22|11111|DEU|Musterhausen|222222222|||||77,00|||eineBic|DE99999999999999999999|eineBic|DE99999999999999999999|REF06jddm4urgqki-02|
|
IBAN: DE99999999999999999999$BIC: eineBic$Spielauftrag: 3000030192$Veranstaltung: Samstag$Spielart: GlücksSpirale$1.Teilnahme: 06.01.2018$Letzte Teilnahme: 29.12.2018$Losnummer: 2290229$Superzahl: 7$Spiel77: Nein$SUPER6: Nein$Anteilssystem: 1/5$%
|
IBAN: DE99999999999999999999$BIC: eineBic$Spielauftrag: 3000030193$Veranstaltung: Samstag$Spielart: GlücksSpirale$1.Teilnahme: 06.01.2018$Letzte Teilnahme: 29.12.2018$Losnummer: 2290226$Superzahl: 7$Spiel77: Nein$SUPER6: Nein$Anteilssystem: 1/5$%
^';
my $regex = qr/\bLosnummer:\s+(\d+)\b/p;
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