# textReplaceOpening()

## `Wrapper.prototype.textReplaceOpening()`

Replaces the [`opening`](https://docs.angular-package.dev/wrapper/wrap/accessors/opening) chars of the [`Wrapper`](https://docs.angular-package.dev/wrapper/wrapper) object in the [`text`](https://docs.angular-package.dev/wrapper/wrap/accessors/text) of the [`Wrapper`](https://docs.angular-package.dev/wrapper/wrapper) object with the given [`opening`](#opening-string) chars.

{% hint style="info" %}
The replacement succeeds if the opening characters exist at the beginning of the text.
{% endhint %}

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

```typescript
public textReplaceOpening(opening: string): string {
  return Wrapper.replaceOpening(this.text, this.opening, opening);
}
```

{% endcode %}

### Parameters

#### `opening: string`

The **opening** chars of [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) to replace in the [`text`](https://docs.angular-package.dev/wrapper/wrap/accessors/text)(part of the primitive value).

### Returns

The **return value** is the [`text`](https://docs.angular-package.dev/wrapper/wrap/accessors/text) of [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type with replaced [`opening`](https://docs.angular-package.dev/wrapper/wrap/accessors/opening) chars.

## Example usage

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

const longText = new Wrapper('{', '}', '{This is a long text}');

// Returns {{This is a long text}}.
longText.valueOf();

// Returns This is a long text}.
longText.textReplaceOpening('');

// Returns {{This is a long text}.
longText.textReplaceOpening('{{');
```
