xpath translatefunction code example

Example: XPath function translate()

translate(string, abc, XYZ)

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 XYZ will replace every occurrence of the first character in abc that appears in string.

Replace 'red' with 'brown' in 'There's a red fox':

translate("There's a red fox","red","brown")

Remove " USD" in "7.99 USD":

translate("7.99 USD"," USD","")

Tags:

Misc Example