Skip to content

Commit

Permalink
Merge pull request #16 from James-Bennett-295/develop
Browse files Browse the repository at this point in the history
Fix ANSI stripping
  • Loading branch information
Scarsz authored Dec 15, 2023
2 parents d3bfc00 + 09a4e3f commit 3986b95
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/me/scarsz/jdaappender/LogItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ protected Set<LogItem> clip(@NotNull HandlerConfig config, int max) {
}

/**
* regex-powered aggressive stripping pattern, see https://regex101.com/r/RDcGRE for explanation
* strip ANSI escape codes
*/
private static final Pattern colorPattern = Pattern.compile("\u001B(?:\\[0?m|\\[38;2(?:;\\d{1,3}){3}m|\\[([0-9]{1,2}[;m]?){3})");
private static final Pattern colorPattern = Pattern.compile("\u001B\\[[\\d;]*m");
public static String stripColors(@NotNull String str) {
return colorPattern.matcher(str).replaceAll("");
}
Expand Down

0 comments on commit 3986b95

Please sign in to comment.