# change() function

The 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*.

**Synonyms:** ereplace(), 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)
```

## See also

- [ereplace() function](https://d3codex.com/pickbasic-flashbasic/ereplace-function/)
- [Statements and functions](https://d3codex.com/pickbasic-flashbasic/statements-and-functions/)
- [swap() function](https://d3codex.com/pickbasic-flashbasic/swap-function/)

---
Source: https://d3codex.com/pickbasic-flashbasic/change-function/ - part of the D3Codex reference.
