replace colon with existing scheme

All about user-defined episode / movie / file name format expressions
Post Reply
nuckles
Posts: 2
Joined: 22 Dec 2017, 00:41

replace colon with existing scheme

Post by nuckles »

i found this scheme in the forum.... {ny.replaceFirst(/^(?i)(The|A|An)\ (.+[^\ \(\d{4}\)])/, /$2, $1/)}

can someone please help add the code to replace colon (:) with dash ( - )

thank you
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: replace colon with existing scheme

Post by kim »

Code: Select all

{ny.replaceFirst(/^(?i)(The|A|An)\ (.+[^\ \(\d{4}\)])/, /$2, $1/)}

Code: Select all

{ny.replaceFirst(/^(?i)(The|A|An)\ (.+[^\ \(\d{4}\)])/, /$2, $1/).replaceAll(/:/,' - ')}
BUT it's better to use (space after) and "replace" to take care of the odd ":" :

Code: Select all

{ny.replaceFirst(/^(?i)(The|A|An)\ (.+[^\ \(\d{4}\)])/, /$2, $1/).replaceAll(/[:–-]/, ' - ').replace(/:/, '.')}

btw:
https://www.filebot.net/naming.html
Last edited by kim on 25 Dec 2017, 05:27, edited 2 times in total.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: replace colon with existing scheme

Post by rednoah »

Since, this is a fairly common request, there's also a convenience method for that:

Code: Select all

n.colon(' - ')
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: replace colon with existing scheme

Post by kim »

rednoah wrote: 23 Dec 2017, 09:07 Since, this is a fairly common request, there's also a convenience method for that:

Code: Select all

n.colon(' - ')
the problem with this is that 99% of English titles with ":" is like "movie: subtitle"
so "n.colon(' - ')" = double spaces
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: replace colon with existing scheme

Post by rednoah »

kim wrote: 23 Dec 2017, 18:33 the problem with this is that 99% of English titles with ":" is like "movie: subtitle"
so "n.colon(' - ')" = double spaces
String.colon() takes care of that particular problem by matching white space surrounding the : colon as well.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: replace colon with existing scheme

Post by kim »

O, but still needs the unicode
... because people copy/paste title in with it, I have even seen the MOD's lock title with it
Post Reply