Page 1 of 1

padding on the Episode (Part 1)

Posted: 15 Oct 2014, 08:31
by DevXen
Is it possible to add a 0 to the (Part 1), (Part 2), etc.
This works great to change from: (1) to (Part 1)

Code: Select all

.replacePart(' (Part $1)'))
But I haven't found a way to add a leading 0 to it.
I've tried: .pad(2), but that didn't work, I would assume as the .replacePart, isn't a string to attach it too.


Thanks,
-Dev

Re: padding on the Episode (Part 1)

Posted: 15 Oct 2014, 09:28
by rednoah
My replacePart function only supports regex replace syntax.

If you do the replaceAll yourself you can pass in your won replacement logic:

Code: Select all

{'Test (1)'.replaceAll("\\s*[(]([^)]*)[)]\$", { group, match -> ' '+match.pad(2) })}

Re: padding on the Episode (Part 1)

Posted: 15 Oct 2014, 21:56
by DevXen
It took a while. but I did get it to work. Thank you, once again for your help.

Re: padding on the Episode (Part 1)

Posted: 01 May 2018, 03:39
by deloppoled
DevXen wrote: 15 Oct 2014, 21:56 It took a while. but I did get it to work. Thank you, once again for your help.
Hi DevXen.

I was wondering if you still have and would mind sharing the format that you got this to work with?

I'm trying to change "Episode 1" to "Episode 01" As a newbee and non-programmer, it's a bit daunting!

Maybe I could make a change to your code where it reads "Part" and change that to "Episode" is what I'm hoping?

If you don't still have that format thank you for time. I'm a registered user so maybe I will ask rednoah, trying to avoid that since I imagine he is a pretty busy guy.

Thank you.
Dan

Re: padding on the Episode (Part 1)

Posted: 01 May 2018, 15:47
by kim
here you go ;)

Code: Select all

{n} - {s00e00} - {t.replaceAll("\\s*[(]([^)]*)[)]\$", { group, match -> ' (Episode '+match.pad(2)+')' })}

Re: padding on the Episode (Part 1)

Posted: 02 May 2018, 15:37
by deloppoled
I can't wait to get home to work with it, this will make my collection look exactly like I need it to.

Thank you very much kim! Have a great day.
Dan

Re: padding on the Episode (Part 1)

Posted: 04 May 2018, 05:45
by deloppoled
Hello.

The code provided didn't seem to do what I probably poorly explained I was trying to do -- that can be expected! :oops:

I played around without a scintilla of success but luckily got some help from my 22 year old son who stopped by to do his laundry. I guess all people his age just 'get it' when it comes to computers.

Here's what he came up with. It seems to do what I was trying to do. Why? Who knows, but it works! :lol:

Code: Select all

{n} - {S00E00} - {t.replaceAll(".*Episode ([1-9])\$", { group, match -> 'Episode '+match.pad(2) })}
A lot of British shows come with "Episode 1" through 9 so this makes them "Episode 01" through 09. And then from Episode 10 onwards, it leaves them as they are. Basically so everything has two digit episode numbers.

I thought I should post this up here in case there's any other 'puter illits that want to do that.

Thank you again for your time kim!
Great days to all.
Dan