Expressions/Rules exchange (1 Viewer)


Portal Member
July 14, 2009
Australia Australia
Country flag
"Staffel N" and "Série N" for German, French/Spanish speakers. Correct previous issue with arbitory characters in front of the filename matching \\.

(?<series>[^\\$]+)(?:(?:\\(?:Season|Staffel|S[eé]ries?)?[ .-]?[0-9]{1,4})?\\s?(?<season>[0-2]?[0-9])|\\(?:(?:Season|Staffel|S[eé]ries?)[ .-])?(?<season>[0-9]{1,4})\\[^\\]*?)[ex]?(?<episode>\d\d+)(?:[ .+-]e?(?<episode2>\d\d+))?(?:[ -]+(?<title>[\w -.,'!&$][^$]*?))?\.(?<ext>[^.]*)$
  • NEW: Foo\Season 2010\s2010e01 - $25K Opening Table.avi
  • root\sub\Foo\Staffel 5\S05E01 Shot title.avi
  • Foo\Série 02\23.avi
  • Foo\Series 02\02x23 - Show title.avi
  • Foo\Season 07\itg-scrubsdb-07x23 - Show title.avi
  • Foo\Season 2\215 Show title.avi
  • Foo\Season 2\02x03 Show title.avi
  • Foo\Season 2\s02e23 Show title.avi
  • Foo\Season 2\02x23-24 Show title.avi
  • Foo\02\02x23 Show title.a
  • Foo\02e23-e24 Show title.av
  • Foo\Season 2\23 Show title.avi
  • Foo\Season 2\23 - Show title.avi
  • Foo\Season 2\e23 Show title.avi
  • Foo\Season 2\23-24 Show title.avi
  • Foo\2\e23+e24 Show title.avi
  • and more combinations that are impossible to list all...

Thanks: dir for 4 digit season numbers and RegEx for special characters in show titles
Last edited:


Extension Developer
  • Premium Supporter
  • March 10, 2006
    Country flag
    Current version:

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

    • foo season 1 episode 01 - *
    • foo season 1 episode 01 + episode 02 - *
    • foo.s01_e01.*
    • foo_[s01]_[e01]_*
    • foo_[s01]_[e01-02]_*
    • foo.1x01.1x02.*
    • foo #1.01 + #1.02.*
    • foo.1x01.1x02.*
    • foo s01e01 - e02*
    • foo s01e01 + s01e02*
    • foo - s01e01 - s01e02 - *
    • foo.2009x101.*
    • foo.S18E203.2010.08.27.*
    • 24.S08E01.04.00.PM-05.00.PM.*
    • and more combinations that are impossible to list all...
    Which is in line with what XBMC supports. Also fixed filenames that contain a '$' sign in the episode title.

    • NEW: Added support for full text 'Season' and 'Episode' in filename
    • NEW: Prevent false positives when filename contains 'date' that uses dots as seperators.
    • NEW: "Foo.S01E01.Bar\Foo.S01E02.Bar.avi" was seen as S01E01, this also caused 'Samples' to be picked up.
    • "Series S01E01 - 2010.08.07.avi" was seen as S01E01 + S01E08 from the new XBMC support
    • "Ben.10.1x23.episode.title" was seen as S10E1 with "x23.episode.title" as Episode title, this removes support for "Show.1.10.Episode.Title" scheme, but just use "Show.#1.10.Episode.Title" then (or "Show - 1.10 - Episode.Title"), which you can do via String Replacement instead of renaming all your files
    • Support added for S01E01E02 and S01E01-E02 pattern
    • New changes should allow for 'The Sample' to be part of episode title without ignoring it as a sample
    Last edited:


    Extension Developer
  • Premium Supporter
  • March 10, 2006
    Country flag
    Expression to support double digit seasons without a seperator:

    ^(?:.*\\)?(?<series>[^\\]+?)[ _.\-\[]+(?:(?<season>\d{2})(?<episode>\d{2})[ _.+\-\[\]]*(?<episode2>\d{2})*)[ _.\-\[\]]*(?<title>(?![^\\].*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$
    • foo.1201.* = foo 12x01
    • foo.2212+13.* = episode 12 + 13
    • and more combinations that are impossible to list all...

    Positioning of this expression is important. If your current "" series are failing your existing expressions for a match, then you can place it at the bottom of the list. However the odds are that some other expression is trying to make a match and causing a false positive, for example thinking it is 1x201. In that case make sure this expression is moved up in the list.


    Retired Team Member
  • Premium Supporter
  • November 14, 2007
    Germany Germany
    Type: Parsing - Regex


    Those 3 simple regex expressions, will match most series correctly. They ignore "Sample" files and folders.
    They search only for the Name, Season and Episode. With these three information only, the grabber finds all my series perfectly.

    The series folder is named correctly and can be found by the grabber of TVSeries.
    Add those expressions before all other rules. (I disabled all other rules.)
    The pattern season and episode patterns SnnEnn or NNxNN must be anywhere in the file path. (Nn = Number)

    Folder structure should be

    C:\Series\<Series Name>\<-- copy all into this folder (sub folder, single files, no matter)


    D:\series\Grey`s Anatomy\Greys.Anatomy.S07E19.Ein.langer.Weg.zurueck.GERMAN.DUBBED.DL.WS.720p.HDTV.x264-euHD\euhd-greys-s07e19-720p.rar

    D:\series\Desperate Housewives\Desperate.Housewives.S07E15.Zuhause.GERMAN.DUBBED.DL.WS.720p.HDTV.x264-euHD\euhd-desperate-s07e15-720p.mkv
    D:\series\Desperate Housewives\sof-desperate.housewives.s07e16.avi

    D:\series\oc\O.C. California - Staffel 1\O.C. California - 1x01 - Fremde Welten.avi

    D:\series\Veronica Mars\Veronica.Mars.S01.COMPLETE.GERMAN.DL.DUBBED.720p.WEB-DL.H.264-TvR\Veronica.Mars.S01E01.Freundschaftsdienste.GERMAN.DL.DUBBED.720p.WEB-DL.H.264-TvR\tvr-veronica-mars-s01e01-720p.mkv



    Portal Member
    November 24, 2006
    Parsing - Regex

    I have my set up as follows:

    "E:\My Documents\Videos\TV\Showname\Season XX\SXXEXX - Episode Title.ext"


    "E:\My Documents\Videos\TV\Bleach\Season 01\S01E01 - Pilot.avi"

    This code works for me :)

    (?<series>[^\\$]+)(?:(?:\\(?:Season|Staffel|S[eé]ries?)?[ .-]?[0-2]?[0-9])?\\s?(?<season>[0-2]?[1-9])|\\(?:(?:Season|Staffel|S[eé]ries?)[ .-])?(?<season>[0-2]?[1-9])\\[^\\]*?)[ex]?(?<episode>\d\d+)(?:[ .+-]e?(?<episode2>\d\d+))?(?:[ -]+(?<title>(?![^\\]*?sample)[^$]*?))?\.(?<ext>[^.]*)$


    Portal Pro
    May 1, 2008
    Parsing - Regex

    I download shows from all over the place and rarely rename them. This is perfect for people that are fine with leaving filenames as they originally were (I.e. to continue to share with torrents and only having to worry about directory structure changes). All "scene" naming conventions are supported here, and more added. I ignore any season numbers from the filenames themselves and grab the season from the 2nd directory. Sample files currently are not ignored since I use MKV/AVI ReSample to .srs files on them, but if they're in a Sample folder within the season folder the regex's could be setup to ignore those easily.

    I hope this helps others out there. I probably won't have time to tweak these for anyone, so just take these and run with them if changes are needed. I just ask that you post your changes if they help.

    I have my series setup as follows:

    Series.Name\*Season 01*\blah.e01.avi
    Series.Name\*Season 1*\blah.101.avi
    - and a ton more to boot

    - Series.Name\EXTRAS\* will be ignored allowing you to place all extras into the series subfolder and not have it parsed.
    - Episode Titles will not be parsed. There are other ones here for people that rename their episodes and have titles.

    These are not the most efficient, but I did it this way to give priority to the higher regex's that i can trust better. I could probably move these all into 1, but I don't care enough to. I would enable each of these 7 in a row as ordered here and uncheck any others.



    MP Donator
  • Premium Supporter
  • August 30, 2006
    Afghanistan Afghanistan
    Type: Parsing -RegEx
    Handles format Cheers\Season 01\s01e01 - blah.avi but also handles:
    seasons greater than 9 (e.g. s32e01)
    4-digit seasons (e.g. s2010e01)
    dollar values in the title (e.g. $25K Final Table)
    So any of the following are valid:
    Expected Filename:
    Aussie Millions\Season 01\s01e01 - Opening Table.avi
    Aussie Millions\Season 01\s01e01-02 - Opening Tables.avi
    Aussie Millions\Season 10\s10e01 - Opening Table.avi
    Aussie Millions\Season 2010\s2010e01 - Opening Table.avi
    Aussie Millions\Season 2010\s2010e01 - $25K Opening Table.avi
    (?<series>[^\\$]+)(?:(?:\\(?:Season?)?[ .-]?[0-9]?[0-9])?\\s?(?<season>[0-9]?[0-9]?[0-9]?[0-9])|\\(?:(?:Season?)[ .-])?(?<season>[0-9]?[0-9]?[0-9]?[0-9])\\[^\\]*?)[ex]?(?<episode>\d\d+)(?:[ .+-]e?(?<episode2>\d\d+))?(?:[ -]+(?<title>[\w -.,'!&$][^$]*?))?\.(?<ext>[^.]*)$


    Extension Developer
  • Premium Supporter
  • March 10, 2006
    Country flag
    Variation of default parsing expression for filename processing:

    ^(?:.*\\)?(?<series>[^\\]+?)[ _.\-\[]+(?:\(.{3,}\)[ _.\-]*)?(?:[s]?(?:eason\s?)?(?<season>\d+)[ _.\-\[\]]*[ex](?:pisode\s?)?(?<episode>\d+)|(?:\#|\-\s)(?<season>(?!(?:\d{4}.\d{2}.\d{2}|\d{2}.\d{2}.\d{4}))\d+)\.(?<episode>\d+))(?:[ _.+-]+(?:[s]?(?:eason\s?)?\k<season>[ _.\-\[\]]*[ex](?:pisode\s?)?(?<episode2>\d+)|(?:\#|\-\s)\k<season>\.(?<episode2>\d+))|(?:[ _.+-]*[ex+-]+(?:pisode\s?)?(?<episode2>\d+)))*[ _.\-\[\]]*(?<title>(?![^\\].*?(?<!the)[ .(-]sample[ .)-]).*?)\.(?<ext>[^.]*)$
    This matches all the default expression files (as stated in:, but it adds the following twist:

    "Show name example (Epsiode title) - S01E01 - BlaBla.ext"

    Is stripped from the "(Episode Title) - " part, so that the "Show name example" can result in a proper match with TheTVdB.

    I do not know of any TheTVdB series that uses parenthesis in their title, but I can not risk that, so this will not become part of the default parsing expression, but a simple manual effort for users who have such a crazy filename scheme.

    PS: Figures, just as I post it I am reminded of "The Office (US)" which would cause a conflict if "(US)" is removed. The only variations I am aware of at TheTVdB is UK and US, which are both 2 letters, so I've modified the expression to only remove "(...)" if the "..." are 3 or more characters (so if you run into an episode title of 2 chars you are screwed). I guess I could look for UK/US specifically, but there might be other country codes in use with TheTVdB that I'm not aware off, so please reply if that's the case or not.
    Last edited:

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    Top Bottom