I am trying to write a common regular expression for the below 3 cases:
- Supernatural_S07E23_720p_HDTV_X264-DIMENSION.mkv
- the.listener.313.480p.hdtv.x264-2hd.mkv
- How.I.met.your.mother.s02e07.hdtv.x264-xor.avi
Now my regular exoression should remove the series name from the original string i,e the output of above string will be:
- S07E23_720p_HDTV_X264-DIMENSION.mkv
- 313.480p.hdtv.x264-2hd.mkv
- s02e07.hdtv.x264-xor.avi
Now for the basic case of supernatural string I wrote the below regex and it worked fine but as soon as the series name got multiple words it fails.
$string =~ s/^(.*?)[\.\_\- ]//i; #delimiter can be (. - _ )
So, I have no idea how to proceed for the aboves cases I was thinking along the lines of \w+{1,6} but it also failed to do the required.
PS: Explanation of what the regular expression is doing will be appreciated.
you can detect if the .’s next token contains digit, if not, consider it as part of the name.
HOWEVER, I personally think there is no perfect solution for this. it’d still meet problem for something like: