using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?!.*\/)(.*)-(([^-]+)-([0-9]+))-([^.]+)(\.chi\.zst)";
string input = @"http://localhost/
http://localhost/packages/a/
http://localhost/packages/b/
http://localhost/packages/c/
http://localhost/packages/core/
http://localhost/packages/d/
http://localhost/packages/e/
http://localhost/packages/f/
http://localhost/packages/g/
http://localhost/packages/h/
http://localhost/packages/i/
http://localhost/packages/j/
http://localhost/packages/k/
http://localhost/packages/l/
http://localhost/packages/m/
http://localhost/packages/meta/
http://localhost/packages/n/
http://localhost/packages/o/
http://localhost/packages/p/
http://localhost/packages/q/
http://localhost/packages/r/
http://localhost/packages/s/
http://localhost/packages/t/
http://localhost/packages/u/
http://localhost/packages/v/
http://localhost/packages/w/
http://localhost/packages/x/
http://localhost/packages/y/
http://localhost/packages/z/
http://localhost/packages/a/atkmm-2.28.2-2-x86_64.chi.zst
http://localhost/packages/a/atom-1.61.0beta0-2-x86_64.chi.zst
http://localhost/packages/a/atril-1.26.0-1-x86_64.chi.zst
http://localhost/packages/a/attica-5.94.0-1-x86_64.chi.zst
http://localhost/packages/a/attr-2.5.1-2-x86_64.chi.zst
http://localhost/packages/a/aubio-0.4.9-13-x86_64.chi.zst
http://localhost/packages/a/aubio-0.4.9-7-x86_64.chi.zst
http://localhost/packages/a/audacious-4.0.5-1-x86_64.chi.zst
http://localhost/packages/a/audacious-plugins-4.0.5-1-x86_64.chi.zst
http://localhost/packages/a/audacity-1:2.4.1-7-x86_64.chi.zst
http://localhost/packages/a/audiofile-0.3.6-6-x86_64.chi.zst
http://localhost/packages/a/audit-3.0.8-1-x86_64.chi.zst
http://localhost/packages/a/augeas-1.12.0-2-x86_64.chi.zst
http://localhost/packages/a/auracle-git-r366.8739929-4-x86_64.chi.zst
";
Match m = Regex.Match(input, pattern);
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