Replacement characters

All about user-defined episode / movie / file name format expressions
Post Reply
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Replacement characters

Post by devster »

Just a small thread to share replacement characters for titles and series names.

Code: Select all

def norm = { it.replaceAll(/[:]/, "\u2236") // "∶" Ratio symbol
               .replaceAll(/[:]/, "\uFF1A") // ":" Fullwidth Colon
               .replaceAll(/[:]/, "\uFE55") // "﹕" Small Colon
               .replaceAll("/", "\u29F8") // "⧸" Big Solidus
               .replaceAll("/", "\u2215") // "∕" Division Slash
               .replaceAll("/", "\u2044") // "⁄" Fraction Slash
               .replaceAll(/[?]/, "\uFE56") // "﹖" Small Question Mark
           }
// remove or comment the ones you don't want
Character appearance may vary depending on your font, in some cases fonts may not have a particular character.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replacement characters

Post by rednoah »

Do we want a built-in convenience method for this operation?

:!: How TF should I name this method!? :lol:
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Replacement characters

Post by devster »

I don't believe it's necessary, there already are the .colon and .slash methods (which I forgot above), the rest can be done with a replaceAll.
In any case a possible name could be "pathsub" or "substitute".
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replacement characters

Post by rednoah »

I guess it's just 3 replacements for now, and that can be expressed with little code already:

Code: Select all

'Test: A / ?'.replace(
	':':'∶',
	'/':'∕',
	'?':'﹖'
)
Let's leave it at that for now. Mainly because I can't come up with a good method name. :lol:
:idea: Please read the FAQ and How to Request Help.
Post Reply