The ereplace() function searches a str.exp for the search.str. If the search.str is at the start occurrence, then replacement.str replaces search.str for the amount specified in occurrences.
ereplace(str.exp, search.str, replacement.str{,occurrences{,start}})
change() swap()
str.exp | String in which the specified search.str is searched. |
search.str | String to search for in str.exp. |
replacement.str | String to replace the specified search.str. |
occurrences | Specifies the number of occurrences of search.str to be replaced by replacement.str. If not specified, the default is 0, which replaces all found occurrences. |
start | Specifies on which occurrence of search string the
replacement begins. If not specified, the default is 1. |
Example 1
This code assigns the value "The old time" to nstring:
nstring = ereplace("The new time","new","old")
Example 2
This code outputs "++-". The ereplace() function replaces two occurrences of "-" starting at the first occurrence.
print ereplace("---","-","+",2,1)