use strict;
my $str = 'https://www.ikea.com/de/de/p/hallbar-abfalltrennungsloesung-mit-auszug-hellgrau-s09308825/
https://www.ikea.com/de/de/p/symfonisk-regal-wifi-speaker-schwarz-50357554/?tduid=d8b332c221610a36288c647f8959959f&utm_medium=affiliate&utm_name=generic&utm_term=conversion&utm_content=deeplink&utm_source=SmartApfel
https://www.ikea.com/de/de/p/symfonisk-tischleuchte-mit-wifi-speaker-weiss-30435157/?tduid=d8b332c221610a36288c647f8959959f&utm_medium=affiliate&utm_name=generic&utm_term=conversion&utm_content=deeplink&utm_source=SmartApfel
https://www.ikea.com/de/de/p/tradfri-gateway-weiss-40337806/?tduid=d8b332c221610a36288c647f8959959f&utm_content=feed&utm_medium=affiliate&utm_name=generic&utm_source=SmartApfel&utm_term=conversion
https://www.ikea.com/de/de/p/fyrtur-verdunklungsrollo-kabellos-batteriebetrieben-grau-40408196/?tduid=d8b332c221610a36288c647f8959959f&utm_content=feed&utm_medium=affiliate&utm_name=generic&utm_source=SmartApfel&utm_term=conversion
https://www.ikea.com/de/de/p/kadrilj-rollo-kabellos-batteriebetrieben-grau-90408127/?tduid=d8b332c221610a36288c647f8959959f&utm_content=feed&utm_medium=affiliate&utm_name=generic&utm_source=SmartApfel&utm_term=conversion';
my $regex = qr/(?:\/p\/|$)(?:[^\/]*)(?<=-)(.*)(?=\/)/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