replaceClosing()
Wrapper.replaceClosing()
Wrapper.replaceClosing()Replaces given closing chars with a given replacement value at the end of the given text.
public static replaceClosing(
  text: string,
  closing: string,
  replaceValue: string
): string {
  return this.hasClosing(text, closing)
    ? text.slice(0, -closing.length) + replaceValue
    : text;
}Parameters
text: string
text: stringThe text of string type in which given closing characters are replaced by a given replacement value.
closing: string
closing: stringThe closing chars of the string to replace by a given replacement value at the end of the given text.
replaceValue: string
replaceValue: stringThe replacement value of a string type for the given closing characters in the given text.
Returns
The return value is the given text of string type with a replaced closing chars by a given replacement value or the specified text unchanged if it does not contain the given closing chars.
Example usage
Single bracket
// 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
// 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=""');Last updated
Was this helpful?
