replaceOpeningIn()

Wrapper.prototype.replaceOpeningIn()

Replaces the opening chars of the Wrapper object in the given text with a given replacement value.

The replacement succeeds if the opening characters exist at the beginning of the text.

wrapper.class.ts
public replaceOpeningIn(text: string, replaceValue: string): string {
  return Wrapper.replaceOpening(text, this.opening, replaceValue);
}

Parameters

text: string

The text of string type in which the opening chars are replaced by given replacement value.

replaceValue: string

The value of string type as a replacement for the opening chars at the beginning of the given text.

Returns

The return value is the given text of string type with replaced opening chars by given replacement value.

Example usage

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

const longText = new Wrapper('{{', '}}', 'This is a long text');
const text = `Lorem ipsum and more`;

// Returns 1. Lorem ipsum and more.
longText.replaceOpeningIn(`${longText.opening}${text}`, '1. ');

// Returns Lorem ipsum and more{{.
longText.replaceOpeningIn(`${text}${longText.opening}`, '??');

Last updated