PickBASIC / FlashBASIC
change() function
.mdThe change() 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.
Synonymsereplace()swap()
Syntax
change(str.exp, search.str, replacement.str{,occurrences{,start}})Parameter(s)
| 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(s)
Example 1
This code assigns the value "The old time" to nstring.
nstring = change("The new time","new","old")
Example 2
This code outputs "++-". The change() function replaces two
occurrences of "-" starting at the first occurrence.
print change("---","-","+",2,1)
Replace every occurrence of a substring
print change("2025-06-06", "-", "/") ;* 2025/06/06