Skip to content

Commit 75bac28

Browse files
Merge pull request #1 from ThaumicTom/main
Fix deformatter to properly handle all cases
2 parents 0871dd4 + 4c0876f commit 75bac28

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/TextFormatter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TextFormatter {
55
* @type {RegExp}
66
* @private
77
*/
8-
static deformatRegex = /(\$[wnoitsgz><]|\$[lh]\[.+\]|\$[lh]|\$[0-9a-f]{1,3})/gi;
8+
static deformatRegex = /\$((\$)|[0-9a-f]{2,3}|[lh]\[.*?\]|.)/gi;
99

1010
/**
1111
* Regex to match all the color formatting codes
@@ -27,7 +27,7 @@ class TextFormatter {
2727
* @returns {string}
2828
*/
2929
static deformat(input) {
30-
return input.replace(this.deformatRegex, "");
30+
return input.replace(this.deformatRegex, "$2");
3131
}
3232

3333
/**

0 commit comments

Comments
 (0)