regexweb-scrapingkodi

Exclude a combination of characters with regex or add a letter


I'm trying to adjust KODI's search filter with regex so the scrapers recognize tv shows from their original file names.

They either come in this pattern: "TV show name S04E01 some extra info" or this "TV show name 01 some extra info" The first is not recognized, because "S04" scrambles the search in a number of ways, this needs to go. The second is not recognized, because it needs an 'e' before numbers, otherwise, it won't be recognized as an episode number.

So I see two approaches.

  1. Make the filter ignore s01-99

  2. prepend an 'e' any freestanding two-digit numbers, but I worry if regex can even do that.

I have no experience in the regex, but I've been playing around coming up with this, which unsurprisingly doesn't do the trick

^(?!s{00,99})\d{2}$

Solution

  • You may either find \b([0-9]{2})\b regex matches and replace with E$1, or match \bs(0[1-9]|[1-9][0-9])\b pattern in an ignore filter.

    Details

    NOTE: If you need to generate a number range regex, you may use this JSFiddle of mine.