chat notifier: fix matching messages with included punctuation
The punctuation is not in \b or \s, so additionally include \z. Also added \A for the beginning, which would have the same problem, which the test also tests for. Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
@@ -120,8 +120,8 @@ public class ChatNotificationsPlugin extends Plugin
|
||||
.map(this::quoteAndIgnoreColor) // regex escape and ignore nested colors in the target message
|
||||
.collect(Collectors.joining("|"));
|
||||
// To match <word> \b doesn't work due to <> not being in \w,
|
||||
// so match \b or \s
|
||||
highlightMatcher = Pattern.compile("(?:\\b|(?<=\\s))(" + joined + ")(?:\\b|(?=\\s))", Pattern.CASE_INSENSITIVE);
|
||||
// so match \b or \s, as well as \A and \z for beginning and end of input respectively
|
||||
highlightMatcher = Pattern.compile("(?:\\b|(?<=\\s)|\\A)(?:" + joined + ")(?:\\b|(?=\\s)|\\z)", Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user