From bad8a1f2c7519ef63350c26b539dfc6aeb9ab94c Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 17 Feb 2022 19:12:57 +0000 Subject: add items --- src/lib/utils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib/utils.ts') diff --git a/src/lib/utils.ts b/src/lib/utils.ts index ae0c5f0..f16021d 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -68,8 +68,11 @@ export function formattingCodeToHtml(formatted: string): string { reset() return htmlOutput } + +// we store the regex here so we don't have to build the object every time +const formattingCodeRegex = new RegExp(colorCodeCharacter + '.', 'g') export function removeFormattingCode(formatted: string): string { - return formatted.replace(new RegExp(colorCodeCharacter + '.', 'g'), '') + return formatted.replace(formattingCodeRegex, '') } function moveToEndOfId(word: string, thing: string) { -- cgit