Created
January 9, 2019 23:05
-
-
Save martinbowling/4db1abde4d1c41e6634f6432c03ddcb9 to your computer and use it in GitHub Desktop.
regex for scene name season and episode numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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