Help with tvshowmatching regex
#1
I was looking over the wiki trying to figure out how to write my own regex for tvshowmatching, but I am having trouble understanding the examples.
Here is the first example given from the wiki:
[Ss]([0-9]+)[][ ._-]*[Ee]([0-9]+)([^\\/]*)$

why is there and empty bracket []? I feel like it does nothing.
what does this part do at the end ([^\\/]*)? I feel like it just matches the rest of the string so long as there are no forward or back slashes.
Reply
#2
There isn't an empty bracket Wink that bit you are referring to means match any of these literal characters ][ ._-

If you look at it again now you will see those literals are enclosed by []* which gives the impression of empty brackets, but actually isn't.

The last bit is match any character zero or more times that isn't \/ so yes, it pretty much does what you said. I imagine this is to make sure that what we are macthing is actually the file, and not the folder portion of the entire filepath.

Regex is still something I struggle with on a regular basis, so I could be wrong, but that's what I think it means!
Learning Linux the hard way !!
Reply
#3
Wouldn't those characters need to be escaped? Like this [\]\[._-]*

Also, are the capture groups () feeding xbmc the series and episode numbers? So the first capture group feeds the series number and the second capture group feeds the episode number? Then the third capture group feeds what?
Reply
#4
*jumps in with both feet again*

Nope, not in that context.
Yes, it is matching S or s then a number between 0-9 any number of times. That gives you for ex 'S02'
Then it matches ][ ._- zero or more times so if your filname contains 'S02 - E04' it would match the <space><dash><space> part. As its zero or more times, if it isn't there it doesn't matter.
Then it matches either E or e and then numbers as per above.
The last bit matches the file extension.

But as I say, I'm certainly no expert. Small regex's I can usually figure but some of the longer ones really mash my head !!
Learning Linux the hard way !!
Reply

Logout Mark Read Team Forum Stats Members Help
Help with tvshowmatching regex0