# 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=""');
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wrapper.angular-package.dev/wrapper/methods/static/replaceclosing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
