use strict;
my $str = 'https://static1.squarespace.com/static/58d6b5ff86e6c087a92f8f89/t/5913df9915cf7db9454ad94a/1494474655305/Plato_and_Hesiod.pdf#page=270
Taylor Swift - New Romantics.m4a
YT/Subto2mp3/Taylor Swift - New Terribly Romantics.m4a
Grow - Conan Blue (Official Video) has already been recorded in archive.m4a
PowerOptim Iol/Techno/(Official Video) Blue Burrow was already been recorded in archive - Bak.wm4
/Great Bun/Output Files/çè/Grow - Conan DARK (Official AUDIO) has already been recorded in archive.m4b
Matter Oil_9999.zip
Qpl$-pol.hrlp/perm.ui.pol/i op/doesn\'t matter.mp4
Small Laser4.m4a
manicur pliu/love is in the a°°_II+?§@R.txt
^Level09\\\\Power Pol\\energy.m4a
lollller_blllade 1987 (c)/super €/music_piece_.mp3
\\.\\.$./../../loli( u1990) _98.lop.pl/fil l/fill2asm.aile.asm.gz.zip
/Taylor Swift - New Romantics._m4a
\\$/Subto2/mp3/Taylor Swift -&- New Romantics.m4a
/Grow - Conan Gray (Official Video) has already been recorded in archive.m4a
C:\\PowerOptim Iol/Grow - The New Gray (Official Video) has been recorded [<1999>.wm4
/Great Bun/Output Files/çè/Grow - WiLlL(O)W Gray "unofficial" video has not been recorded in archive.m4b
/Matter Oil_9999.zip
file:///Qpl$-pol.hrlp/perm.ui.pol/i op/matter.mp4
/£¥«^6<4>à_»Laser4 ``[12{2%}32]deg`‘.webm
manicur pliu/great.power.great.responsibility?.gz.tar.zip
./poi kiol/greater.power.greater.responsibility!.gz.tar.zip
^Level09\\Power Pol\\energy.m4a
lollller_blllade 1987 (c)/super €/music_piece_.mp3
/The \'great\' solitude of zorro #12/the 退ellent urge_for.mo.tar.gz
';
my $regex = qr/^(?:.*[\/\\])?(?<FileNameWithoutExtension>.*)\.(.*?(?=\#))/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