Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Trying to make a regular expression for the TV-Series plugin for MediaPortal (never used regexp before). Basically it matches a file name with a certain TV series, season, episode, etc.

I have files in a directory being searched like this:

\Sport\Football\Match of the Day\2011-2012\Match of the Day (2011-12-10) [1080i].mkv
\Sport\Football\Match of the Day\2011-2012\Match of the Day (2011-12-17) [1080i].mkv
\Sport\Football\Match of the Day\2011-2012\Match of the Day (2011-12-24) [1080i].mkv
etc.


I'm using the following regexp but it doesn't work and it doesn't even seem to match any part of the file names:

Sport\\Football\\Match of the Day\\201[0-9]-201[1-9]\\<series>\s\(<firstaired>\).<ext>


"series", "ext" and "firstaired" are supposed to be fed into the program. I've also tried ignoring the directory structure (as some of the built-in regular expressions do):

<series>\s\(<firstaired>\).<ext>


but this doesn't work either. :/

Here's a couple of examples of built-in regular expressions that also fail to detect these files:

^(?:.*\\)?(?<series>[^\\]+?)[ _.\-\[]+(?:[s]?(?<season>\d+)[ _.\-\[\]]*[ex](?<episode>\d+)|(?:\#|\-\s)(?<season>\d+)\.(?<episode>\d+))(?:[ _.+-]+(?:[s]?\k<season>[ _.\-\[\]]*[ex](?<episode2>\d+)|(?:\#|\-\s)\k<season>\.(?<episode2>\d+))|(?:[ _.+-]*[ex+-]+(?<episode2>\d+)))*[ _.\-\[\]]*(?<title>(?![^\\].*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$


(?<series>[^\\\[]*) - \[(?<season>[0-9]{1,2})x(?<episode>[0-9\W]+)\](( |)(-( |)|))(?<title>(?![^\\]*?sample)[^$]*?)\.(?<ext>[^.]*)

(^.*?\\?(?<series>[^\\$]+?)[ .-]+(?<firstaired>\d{2,4}[.-]\d{2}[.-]\d{2,4})[ .-]*(?<title>(?![^\\]*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$)


Thanks for any ideas!
Posted

1 solution

For Regular Expressions Learning you may see this softwares:
Expresso form http://www.ultrapico.com
csharpregexdemo
RegEx Builder form http://www.SoftPedia.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900