# string.replace-multiple()

The `string.replace-multiple()` function handles multiple string replaces, using [`string.replace()`](https://docs.angular-package.dev/sass/string/string.replace) function.

{% code lineNumbers="true" %}

```scss
// Modules.
@use 'string.replace.function';

// The `string.replace-multiple()` function.
@function replace-multiple($string, $replaces...) {
  @each $occurrence, $substring, $replacement in $replaces {
    $string: string.replace($string, $occurrence, $substring, $replacement);
  }
  @return $string;
}
```

{% endcode %}

{% embed url="<https://github.com/angular-package/sass/blob/main/string/_string.replace-multiple.function.scss>" %}
string.multiple-replaces()
{% endembed %}

### Parameters

#### **`$string`**

The string to do multiple [`$replaces`](#usdreplaces...).

#### `$replaces...`

Arbitrary replaces (occurrence, substring, replacement) to do on [`$string`](#usdstring).

### Return

The return value is a `string` with done [`$replaces`](#usdreplaces...).

## Examples

```scss
// Use.
@use '@angular-package/sass/string';

// Examples.
// single replacement first occurrence
@debug string.replace-multiple('bold king is hairy', first 'bold' 'baloon'); // baloon king is hairy
@debug string.replace-multiple('bold king is hairy', first 'bold' ''); //  king is  hairy
@debug string.replace-multiple(':==', first ':' '');

// single replacement all occurrences
@debug string.replace-multiple('bold king is bold hairy', all 'bold' ''); //  king is  hairy
@debug string.replace-multiple('bold king is bold hairy', all 'bold' 'test'); // test king is test hairy

// multiple replacements
@debug string.replace-multiple('bold king is hairy', first (bold is) ''); //  king  hairy
@debug string.replace-multiple('bold king is hairy', first bold baloon, first king baloon); // baloon baloon is hairy
@debug string.replace-multiple('bold king is hairy', first (bold king) baloon, first (is hairy) bold); // baloon baloon bold bold
@debug string.replace-multiple('atmosphere bold bold bold king is hairy', first (king bold) baloon); // atmosphere baloon bold bold baloon is hairy
@debug string.replace-multiple('atmosphere bold bold bold king is hairy', all (king bold) baloon); // atmosphere baloon baloon baloon baloon is hairy

// multiple replacements different occurrences
@debug string.replace-multiple('atmosphere bold bold bold king is hairy', first bold clean, all (king bold) baloon); // atmosphere clean baloon baloon baloon is hairy

```
