Class: String
Description
This method returns a string that results from replacing or dropping characters in its first parameter as specified by the pattern in its second parameter.
Syntax
StringObject.translate(String lookFor,String replaceBy)
Parameters
lookFor |
The characters to look for. |
replaceBy |
The characters to replace when a matched character is found. |
Returns
A String.
When Became Available
v6.4
Example
type String STR = "Be-a-king!"
// Replace: "Be^a^king?"
type String TR1 = STR.translate("!-","?^")
// Remove: "Beaking"
type String TR2 = STR.translate("!-")
// Combined replace/remove: BeAKing
type String TR3 = STR.translate("ak-!","AK")
// Dangerous example, duplicate in lookFor: "Be#a#king!"
type String TR4 = STR.translate("--","#@")