use strict;
my $str = '[29.01.18, 23:33] Alice: Ist das hier ein Chatverlauf?\\n[29.01.18, 23:45] Bob: Ja ist es!\\n[29.01.18, 23:45] Bob: Der ist dazu da die funktionsweise des Parsers zu demonstrieren\\n[29.01.18, 23:46] Alice: PTT-20180129-WA0025.opus (Datei angehängt)\\n[29.01.18, 23:46] Bob: Ah, er kann also auch erkennen ob Voicemails gesendet wurden!\\n[29.01.18, 23:46] Bob: Das ist praktisch!\\n[29.01.18, 23:47] Bob: Oder?\\n[29.01.18, 23:47] Alice: ja😄\\n[29.01.18, 23:47] Alice: und Emojis gehen auch!\\n[29.01.18, 23:47] Bob: Was ist mit normalen Smilies?\\n[29.01.18, 23:49] Alice: Keine Ahnung, lass uns das doch mal ausprobieren\\n[29.01.18, 23:50] Bob: Alles klar :) :D\\n[29.01.18, 23:51] Alice: Scheint zu funktionieren!:P\\n[29.01.18, 23:51] Bob: Meinst du, dass URLS auch erkannt werden?\\n[29.01.18, 23:52] Bob: Schick doch mal eine zum ausprobieren!\\n[29.01.18, 23:53] Alice: https://github.com/JuKo007\\n[29.01.18, 23:58] Alice: Scheint zu funktionieren!\\n[29.01.18, 23:59] Alice: Sehr schön!\\n[30.01.18, 00:00] Alice: Damit sollten sich WhatsApp Verläufe besser quantifizieren lassen!\\n[30.01.18, 00:02] Bob: Alles klar, los gehts 😌\\n';
my $regex = qr`(?=\[\d\d.\d\d.\d\d, \d\d:\d\d\])`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