Please enable JavaScript to view this site.

Altova MapForce 2022 Basic Edition

Performs a character by character replacement. It looks in the value for characters contained in string1, and replaces each character for the one in the same position in the string2. When there are no corresponding characters in string2, the character is removed.




Built-in, C++, C#, Java, XQuery, XSLT 1.0, XSLT 2.0, XSLT 3.0.






The input string.


Provides a list of search characters. The position of each character inside the string is important.


Provides a list of replacement characters. The position of each replacement character must correspond to the one in string1.



Let's suppose you want to convert the string [12,3] to (12.3). Namely, the square brackets must be replaced by round brackets, and any comma must be replaced by the dot character. To achieve this, you can call the translate function as follows:


In the mapping above, the first constant supplies the input string to be processed. The second and the third constant provide a list of characters as string1 and string2, respectively.







Notice that both string1 and string2 have the same number of characters. For each character in string1, the equivalent character at the same position from string2 will be used as a replacement. Consequently, the following replacements will take place:


Each [ will be replaced by a (

Each , will be replaced by a .

Each ] will be replaced by a ]


The mapping output is as follows:




This function can also be used to strip certain characters selectively from a string. To achieve this, set the string1 parameter to the characters you want to remove, and string2 to an empty string. For example, the mapping below removes all digits from the string 38ab8a7a65xkh3.


The mapping output is as follows:



© 2015-2021 Altova GmbH