Path: blob/main/files/en-us/web/xpath/functions/translate/index.md
6543 views
------{{ XsltRef() }}
The translate function evaluates a string and a set of characters to translate and returns the translated string.
Syntax
Arguments
string: The string to evaluate.
abc: The string of characters that will be replaced.
XYZ: The string of characters used for replacement. The first character in
XYZwill replace every occurrence of the first character inabcthat appears instring.
Returns
The translated string.
Notes
XPath notes that the translate function is not a sufficient solution for case conversion in all languages. A future version of XPath may provide additional functions for case conversion.
However, this is the closest we have at present to a function that can convert a string to uppercase or lowercase.
Example
Output
If
abcis longer thanXYZ, then every occurrence of characters inabcthat do not have a corresponding character inXYZwill be removed.
Example
Output
If
XYZcontains more characters thanabc, the extra characters are ignored.
Defined
Gecko support
Supported.