> For the complete documentation index, see [llms.txt](https://wrapper.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wrapper.angular-package.dev/wrapper/methods/static/replaceclosing.md).

# replaceClosing()

## `Wrapper.replaceClosing()`

Replaces given [`closing`](#closing-string) chars with a given [replacement value](#replacevalue-string) at the end of the given [`text`](#text-string).

{% code title="wrapper.class.ts" %}

```typescript
public static replaceClosing(
  text: string,
  closing: string,
  replaceValue: string
): string {
  return this.hasClosing(text, closing)
    ? text.slice(0, -closing.length) + replaceValue
    : text;
}
```

{% endcode %}

### Parameters

#### `text: string`

The **text** of [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type in which given [`closing`](#closing-string) characters are replaced by a given replacement [value](#replacevalue-string).

#### `closing: string`

The **closing** chars of the [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) to replace by a given replacement value at the end of the given [`text`](#text-string).

#### `replaceValue: string`

The replacement value of a [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type for the given [`closing`](#closing-string) characters in the given [`text`](#text-string).

### Returns

The **return value** is the given [`text`](#text-string) of [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type with a replaced [`closing`](#closing-string) chars by a given [replacement value](#replacevalue-string) or the specified [`text`](#text-string) unchanged if it does not contain the given [`closing`](#closing-string) chars.

## Example usage

### Single bracket

```typescript
// Example usage.
import { Wrapper } from '@angular-package/wrapper';

const quote = new Wrapper('[', ']', 'quote');

// Returns [quote> of string.
Wrapper.replaceClosing(quote.valueOf(), ']', '>');

// Returns [quote}} of string.
Wrapper.replaceClosing(quote.valueOf(), ']', '}}');
```

### Triple bracket

```typescript
// Example usage.
import { Wrapper } from '@angular-package/wrapper';

const quote = new Wrapper('[[', ']]', '[quote]');

// Returns [[[quote]]> of string.
Wrapper.replaceClosing(quote.valueOf(), ']', '>');

// Returns [[[quote]]}} of string.
Wrapper.replaceClosing(quote.valueOf(), ']', '}}');

// Returns [[[quote} of string.
Wrapper.replaceClosing(quote.valueOf(), ']]]', '}');

// Returns [[[quote] style="" of string.
Wrapper.replaceClosing(quote.valueOf(), quote.closing, ' style=""');
```
