Page 1 of 1

replace colon with existing scheme

Posted: 22 Dec 2017, 02:57
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

Re: replace colon with existing scheme

Posted: 22 Dec 2017, 17:33
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

Re: replace colon with existing scheme

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

Code: Select all

n.colon(' - ')

Re: replace colon with existing scheme

Posted: 23 Dec 2017, 18:33
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

Re: replace colon with existing scheme

Posted: 24 Dec 2017, 15:50
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.

Re: replace colon with existing scheme

Posted: 25 Dec 2017, 05:24
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