From 882223b27f684cbc9c02b4365f4f3728862a808a Mon Sep 17 00:00:00 2001 From: tbrose Date: Tue, 7 Dec 2021 02:38:10 +0100 Subject: [PATCH] Using static call and verbatim symbol and optimizes regex pattern for username check --- osu.Game/Online/Chat/MessageNotifier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Chat/MessageNotifier.cs b/osu.Game/Online/Chat/MessageNotifier.cs index 883f6a7284..db7c5e47f5 100644 --- a/osu.Game/Online/Chat/MessageNotifier.cs +++ b/osu.Game/Online/Chat/MessageNotifier.cs @@ -134,7 +134,7 @@ namespace osu.Game.Online.Chat { string fullName = Regex.Escape(username); string underscoreName = Regex.Escape(username.Replace(' ', '_')); - return new Regex($"(^|^\\W|\\W|\\w\\W)({fullName}|{underscoreName})($|$\\W|\\W|\\w\\W)", RegexOptions.IgnoreCase).IsMatch(message); + return Regex.IsMatch(message, $@"(^|\W)({fullName}|{underscoreName})($|\W)", RegexOptions.IgnoreCase); } public class PrivateMessageNotification : OpenChannelNotification