From bb37401028a543a7ceec76de828f36b8aba0805f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 24 Apr 2018 12:31:37 +0200 Subject: [PATCH] do not match mentions on word boundries but only when preceeded by white space --- .../siacs/conversations/services/NotificationService.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index ca71da248..c061cae5c 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -702,13 +702,7 @@ public class NotificationService { } public static Pattern generateNickHighlightPattern(final String nick) { - // We expect a word boundary, i.e. space or start of string, followed by - // the - // nick (matched in case-insensitive manner), followed by optional - // punctuation (for example "bob: i disagree" or "how are you alice?"), - // followed by another word boundary. - return Pattern.compile("\\b" + Pattern.quote(nick) + "\\p{Punct}?\\b", - Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); + return Pattern.compile("(?<=(^|\\s))" + Pattern.quote(nick) + "\\b", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); } public void setOpenConversation(final Conversation conversation) {