Introduction
Useful Sites
MC and Regex
Regex Testing
Regex Order
MC includes three regexs which cover the three most common naming conventions.
Examples:
For season one, episode two
These three will work for the vast majority of content because they are case insensitive, and will recognize up to four digit numbers for each set, the season and the episode number; or in the third case, an infinite number of seasons with up to 99 episodes each.
If there is some odd-ball convention used in the naming of some of your media, it may be possible to avoid having to edit the names of all the files by creating a custom Regex.
Because it works as is more often than not, and because adding more may lead to further complications, we will not give you additional regexs here, but we will give you the tools you need to create your own.
Before getting started, and getting frustrated, be sure to read all the way through this page for a better understanding of how MC uses the Regexs.
The XBMC Wiki has a nice selection of additional regexs. The ones listed there are extremely specific, but one of them be just what you need. Even if none of them is exactly what you are looking for, it is useful to see the differences between the regexs compared to what they do.
Regular-expressions.info and the Microsoft Developer Network both offer reference sheets with explanations and examples to help understand what you are looking at when reading a regex and help with ideas for what can be done with them.
When you are ready to start building your own it may be useful to test them on MyRegexTester.com.
A neat site where you can input your regex and some text to test it against, it can give you an explanation of the regex, and also tell groups captured, which are what MC will read as the season and episode numbers.
MC employs a regex in such a way that whatever matches against the first set of parenthesis () in the regex returns the season number, and the second set returns the episode number.
Ex. A(?:a)?B(b)?C(c)? this would look for the A or a before returning the B or b and the C or c.
If you've finished testing a regex in the regex section and are now ready to put it to use, but it may be a good idea to give it a "real life" test of ID'ing the show you are working with before allowing it to be tested against everything in the main browser.
The order of the regexs can be rearranged in MC. This is important to note because they are run through in order from top to bottom when MC is trying to get the season and episode numbers, so you will probably want to leave any regex you add to MC at the bottom, especially if it's something you are unsure of. This way it is less likely that MC make changes to media that has already been properly identified.
On the other hand, one regex may id the majority of shows correctly but misidentify one show; while a regex below it on the list would identify that one show correctly but could misidentify other shows incorrectly.
This should not be an issue unless you are using custom regexes, but an example would be:
[\Shows\Sealab 2021\Season 1\02.avi]
You could make a regex that gets the season number from the folder name since the regexes are tested against the entire file path; we'll call that one the S1\02 regex. In this particular case, the S1\02 regex would clash with the 102 regex that comes with MC.
Using the same example of [\Shows\Sealab 2021\Season1\...]
* Leaving the 102 regex ahead of the S1\02 regex would cause all the episodes of the show to be identified as Season 20 Episode 21 since it uses the first match it gets to.
* Switching the order of the 102 and S1\02 regexs would solve the problem for that specific show, but could mess up other shows by identifying the season number from the folder name and identifying the season number from the file name as the episode number.
To properly address this problem, the S1\02 regex can be temporarily moved up in the order list, and that specific show can be searched for new episodes. Now that the shows episodes have been id'd correctly the regex order can be changed back to prevent problems with other shows.
Note that restarting, closing and re-opening, MC is required every time the regex order is changed.
If you create a regex that you find particularly useful, feel free to post it in the comments section below along with an explanation and example.
Wiki: GenPrefs
Wiki: TVPrefTab
Wiki: TVSeries
Wiki: showstroubleshooting