use strict;
my $str = '3/30/20, 17:06 - Me: Hi brow! I need to test some regex.
3/30/20, 17:06 - John Doe: πππ Let\'s do it!
3/30/20, 17:08 - Me: β‘οΈπ¦π§ππ€ͺπΊπͺπΎπ½πππ―β
π―π΅ πβ‘οΈπΆπ΄ππ½
3/30/20, 17:10 - Someone: π΅ππππ We\'re talking emoji language?
https://regex101.com/library';
my $regex = qr/(^(?<date>\d{1,2}\/\d{1,2}\/\d{1,2}),\s(?<time>\d{1,2}:\d{1,2})\s-\s(?<user>.*?):\s)|(?<word>\w+(?:\'\w+)?|[\x{1F600}-\x{1F64F}]|[\x{1F300}-\x{1F5FF}]|[\x{1F680}-\x{1F6FF}]|[\x{2600}-\x{26FF}]|[\x{2700}-\x{27BF}]|[^\w\s~"!@#$%*()_+-=ΒΉΒ²Β³Β§ΒͺΒΊ`^{}[\]<>,.;:?\/\\\|\n\r\t])/mup;
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