aboutsummaryrefslogtreecommitdiff
path: root/src/lib/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/utils.ts')
-rw-r--r--src/lib/utils.ts5
1 files changed, 4 insertions, 1 deletions
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) {