replaceMultipleCharacters

Modified on Wed, 16 Aug 2023

Description

Replace multiple characters in a string according to a given mapping

Syntax

replaceMultipleCharacters(text, replacements)

Parameters

Input ParameterTypeDescription
textstringThe input string to perform replacements on
replacementsobjectAn object containing characters to replace and their corresponding replacements

Return value

Type
string

Sample

ExampleResultDescription
replaceMultipleCharacters('a quick brown fox jumps over the lazy dog', { 'a': 'b', 'e': 'f', 'o': 'x' })'b quick brxwn fxx jumps xvfr thf lbzy dxg'The result string with specified characters replaced

To view all the String functions, click here.

See Also