Important
|
Deprecated in 5.0. Replaced with method replace() of the string instance. |
replace(string, old, new) => String
Returns the string with all the occurrences of old substring replaced with the new substring. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaa" will result in "ba" rather than "ab".
string |
String |
The string which will be processed. |
old |
String |
Old substring to be replaced |
new |
String |
The new substring, which would replace the old substring. Can be an empty string. |
Return
Source string with substrings replaced.
Example
println(replace("one four three","four","two")); //Will print "one two three" println(replace("abc def"," ","")); //Will print "abcdef"