hasOpening()
Wrap.hasOpening()
Wrap.hasOpening()Checks whether the text has given opening chars at the beginning.
public static hasOpening(text: string, opening: string): boolean {
return (
typeof text === 'string' &&
text.length >= 1 &&
typeof opening === 'string' &&
opening.length >= 1 &&
text.slice(0, opening.length) === opening
);
}Parameters
text: string
text: stringThe text of string, to check whether it contains given opening chars.
opening: string
opening: stringThe opening chars of string to check if a given text contains.
Returns
The return value is a boolean indicating whether the text contains opening chars at the beginning.
Example usage
Last updated
Was this helpful?