diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-29 23:25:27 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-29 23:25:27 +0200 |
commit | 79419107b17585ab4b184939c0ec84f29fa7c803 (patch) | |
tree | 350985bfe96f1c216e9831d19f37d27a9e8ba7fd /src/main/java | |
parent | 9a22917951a9dacc9470633f94b769c4d7187943 (diff) |
do not match mentions on word boundries but only when preceeded by white space
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/NotificationService.java | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index cb76691a7..a823c8307 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -74,13 +74,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 boolean notify(final Message message) { |