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" |
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for