I'm trying to match a specific TV edge and break the match:
MyTV Show .09E01.HDTV.xvd
Maitivi Show10E 02.HDTV.xvd
Maitivi 9 9 HDTV XVID
Maitivi Show.1102.HDTV. XVD
I am trying to break these stars in three capture groups for these entries: Title, Season, Episode.
I can handle 2 simple enough before:
^ ([a-zA-Z0-9.] *) S ([0- 9] {1,2}) E ([0- 9] {1,2}). $$
However, it is difficult to break the third and fourth seasons and episodes. If I can work backwards, then it will be easy. For example, with "901", if I can work backwards, then it will be the first digit to get points, before anything else is a season number.
Do anyone have any suggestions on how I can break these stars into those relevant capture groups?
What will I use here:
(. *?) \. s? (\ D {1,2}) E? (\ D {2}) \. (. *)
Capture groups are:
1: name 2: season 3: episode 4: remaining
< Hr> Here are some code C # (Courtesy):
using the system; Using System.Text.RegularExpressions; Public Sector Test {Public Stable Zero Main () {String S = @ "Matt TV Show .09E01.HDTV.xvit MTV Show.10E 02.HDTV.exyd MIT Show901.HDTV.XVid IIT Show.1102.HDTV.XviD "; Remove (s); } Private static Readonly Reggaex Rx = New Regex (@ "(* *)? S? (\ D {1,2})? E (? \ D {2}) \. (. *)", Regex opption. Ignore case) ; Static Zero (string lesson) {match clutter = Rx. Matches (text); (Match Match in matches) {console. Merge Line ("Name: {0}, Season: {1}, AP: {2}, Content: {3} \ n", Match Group [1] .Ostring () Trim (), Match Group [2] ], Match, group [3], match, group [4]. Ostring (.) Trim ()); }}}
produces:
Name: MyTV.Show, Season: 09, Ep: 01, Contents: HDTV. XVID Name: MyTV.Show, Season: 10, App: 02, Stuff: HDTV. XVid Name: MiteView Show, Season: 9, AP: 01, Stuff: HDTV. XVID name: MiteView Show, Season: 11, AP: 02, Stuff: HDTV.XviD
Comments
Post a Comment