Share via


translate Function (Compact 2013)

3/26/2014

Returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string.

Syntax

string translate(string, string, string)

Parameters

  • string
    A string.
  • string
    Characters to be replaced.
  • string
    Replacement characters.

Return Value

Returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string.

Remarks

The following function call returns "BAr".

translate("bar","abc","ABC")

If there is a character in the second argument string with no character at a corresponding position in the third argument string (because the second argument string is longer than the third argument string), occurrences of that character in the first argument string are removed.

The following function call returns "AAA".

translate("--aaa--","abc-","ABC")

If a character occurs more than once in the second argument string, the first occurrence determines the replacement character. If the third argument string is longer than the second argument string, excess characters are ignored.

If an argument is not of type string, it is first converted to a string and then evaluated.

See Also

Reference

XPath String Functions