translate()

Replaces a set of characters ('searchList') with another set of characters ('replacementList') in a given a string. The function searches for characters in the 'searchList' and replaces them with the corresponding characters in 'replacementList'

Syntax

translate(searchList, replacementList, source)

Learn more about syntax conventions.

Parameters

Name Type Required Description
searchList string ✔️ The list of characters that should be replaced.
replacementList string ✔️ The list of characters that should replace the characters in searchList.
source string ✔️ A string to search.

Returns

source after replacing all occurrences of characters in 'replacementList' with the corresponding characters in 'searchList'

Examples

Input Output
translate("abc", "x", "abc") "xxx"
translate("abc", "", "ab") ""
translate("krasp", "otsku", "spark") "kusto"