# replaceOpening()

## `Wrapper.replaceOpening()`

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

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

```typescript
public static replaceOpening(
  text: string,
  opening: string,
  replaceValue: string
): string {
  return this.hasOpening(text, opening)
    ? text.replace(opening, String(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 the given [`opening`](#opening-string) chars are replaced by a given [replacement value](#replacevalue-string).

#### `opening: string`

The opening chars of the [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) to replace by a given [replacement value](#replacevalue-string) at the beginning 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 [`opening`](#opening-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 [`opening`](#opening-string) chars by a given [replacement value](#replacevalue-string) or the specified [`text`](#text-string) unchanged if it does not contain the given [`opening`](#opening-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.replaceOpening(quote.valueOf(), '[', '<');

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

### Triple bracket

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

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

// Returns <[[quote]]] of string.
Wrapper.replaceOpening(quote.valueOf(), '[', '<');

// Returns {{[[quote]]] of string.
Wrapper.replaceOpening(quote.valueOf(), '[', '{{');

// Returns {quote]]] of string.
Wrapper.replaceOpening(quote.valueOf(), '[[[', '{');

// Returns style=""[quote]]] of string.
Wrapper.replaceOpening(quote.valueOf(), quote.opening, ' 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/replaceopening.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.
