using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?:.*[\/\\])?(?<FileNameWithoutExtension>.*)\.(.*?(?=\#|\?|$))";
string input = @"http://www.cultureandcosmos.org/pdfs/2-2/Voss_Music_Spheres.pdf#456
https://static1.squarespace.com/static/58d6b5ff86e6c087a92f8f89/t/5913df9915cf7db9454ad94a/1494474655305/Plato_and_Hesiod.pdf#page=270
http://www.cultureandcosmos.org/pdfs/2-2/Voss_Music_Spheres.pdf?power=222p#11
https://archive.flossmanuals.net/inkscape/_booki/inkscape/inkscape.pdf
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
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx