Page 1 of 1
Need Regex Help
Posted: March 29th, 2010, 6:35 pm
by randyharris
The script below in the code box is from a locked thread so I had to start a new one.
Instead of how the example is done below, I would like to get a regex= line for shows the this format:
TV Show - SxxExx.ext
e.g.: Lost - S06E11.m4v
Thanks for your help.
Code: Select all
# regex to match job name to strip out show name, season number, episode number and episode name
# in multi part episodes (eg: Show - 1x01-1x02 - Episode), the first episode (1 in this case) is used
regex="^(.*) - ([[:digit:]])+x([[:digit:]]+).* - (.*)$"
Re: Need Regex Help
Posted: March 30th, 2010, 3:26 am
by Camelot
untested:
Code: Select all
regex="^(.+) - S([[:digit:]]+)E([[:digit:]]+).*$"
This will accept something of the format:
"Show name - SxxExx"
which should do the job for you. It will place the showname in placeholder 1, season number in 2 and episode number in 3.
hope that helps
Re: Need Regex Help
Posted: March 30th, 2010, 11:56 am
by randyharris
Thanks I'll give this a test.
Camelot wrote:
untested:
Code: Select all
regex="^(.+) - S([[:digit:]]+)E([[:digit:]]+).*$"
This will accept something of the format:
"Show name - SxxExx"
which should do the job for you. It will place the showname in placeholder 1, season number in 2 and episode number in 3.
hope that helps
Re: Need Regex Help
Posted: March 30th, 2010, 4:06 pm
by doubledrat
you might want to make it case insensitive with
Code: Select all
regex="^(.+) - [Ss]([[:digit:]]+)[Ee]([[:digit:]]+).*$"
Re: Need Regex Help
Posted: March 30th, 2010, 11:51 pm
by randyharris
doubledrat wrote:
you might want to make it case insensitive with
Code: Select all
regex="^(.+) - [Ss]([[:digit:]]+)[Ee]([[:digit:]]+).*$"
Thanks doubledrat,
working on the same script - wonder if you could help with this one too...
(case insensitive would be best)
Here is the file name format:
"Formula1.2010.Australian.Grand.Prix.WS.PDTV.XviD-433.avi"
Where it is always going to be SERIES.YEAR.VENUE.garbage
More verbose - the start of the name to but not including the first period is the "Series", the 4 digits between the first and second period is the "YEAR", and between the second and third period is the "Venue"
Also need to figure out how put the three of those together to create the Episode name so that the name would be:
Formula1 2010 - Australia
Thanks if you or anybody can help.
Re: Need Regex Help
Posted: April 1st, 2010, 6:10 pm
by randyharris
I took a stab at the regex command but it isn't working...
regex="^([a-zA-Z]+*)\.(20[0-9][0-9])\.([a-zA-Z]+)\..*$"
Re: Need Regex Help
Posted: April 2nd, 2010, 5:03 am
by doubledrat
well, you can do what you've asked to do with
which will match digits or letters, then a . then a year, then everything else
but what if you have something like
only.the.lonely.2009.blah.blah.blah.avi
I think you need to drop looking for the .
this will give you
Formula1.
2010
.Australian.Grand.Prix.WS.PDTV.XviD-433
so you'd need to tidy up a bit
Re: Need Regex Help
Posted: April 2nd, 2010, 5:31 am
by doubledrat
this might be better
Code: Select all
^(.+)(20[0-9][0-9])(.+?)([A-Z]{2,})(.*)\....$
will give
Formula1.
2010
.Australian.Grand.Prix.
WS
.PDTV.XviD-433
^ start of string
(.+) any char at least once
(20[0-9][0-9]) a year
(.+?) any char at least once (lazy)
([A-Z]{2,}) any uppercased word with at least 2 letters
(.*) anything else
\. a dot
...$ any 3 chars then the end of the string
you'll then need to remove dots from your strings and trim any leading/trailing spaces, but that should be good to go.
Re: Need Regex Help
Posted: April 2nd, 2010, 8:46 pm
by randyharris