Skip to content

Instantly share code, notes, and snippets.

@martinbowling
Created January 9, 2019 23:05
Show Gist options
  • Save martinbowling/4db1abde4d1c41e6634f6432c03ddcb9 to your computer and use it in GitHub Desktop.
Save martinbowling/4db1abde4d1c41e6634f6432c03ddcb9 to your computer and use it in GitHub Desktop.
regex for scene name season and episode numbers
string sample = "Stargate.SG-1.S01E08.iNT.DVDRip.XviD-LOCK.avi";
Regex regex = new Regex(@"S(?<season>\d{1,2})E(?<episode>\d{1,2})");
Match match = regex.Match(sample);
if (match.Success)
{
string season = match.Groups["season"].Value;
string episode = match.Groups["episode"].Value;
Console.WriteLine("Season: " + season + ", Episode: " + episode);
}
else
{
Console.WriteLine("No match!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment