[SNIPPET] Replace Characters, Words or Patterns

All about user-defined episode / movie format expressions
Post Reply
User avatar
rednoah
The Source
Posts: 21960
Joined: 16 Nov 2011, 08:59

[SNIPPET] Replace Characters, Words or Patterns

Post by rednoah »

e.g. Replace custom text:

Code: Select all

{ n.replace('apple' : 'orange' ) }


e.g. Strip : and - and replace & with and:

Code: Select all

{
	n.replace(
		':' : '',
		'-' : '',
		'&' : 'and'
	)
}


e.g. Replace German Umlauts:

Code: Select all

{ n.replace(ä : 'ae', ö : 'oe', ü : 'ue') }


e.g. Read replacement map from an external CSV or TSV file:

Code: Select all

{ n.replace(csv('/path/to/replace.csv')) }
/path/to/replace.csv

Code: Select all

ä	ae
ö	oe
ü	ue
:idea: Please read the FAQ and How to Request Help.
Post Reply