From 77942a94c83ca53e06ef29f841def12e5fa5633f Mon Sep 17 00:00:00 2001 From: Federico Iosue Date: Wed, 19 Dec 2018 17:27:44 +0100 Subject: [PATCH] Fixed tags removal when sharing common prefix (fix #634) --- .../java/it/feio/android/omninotes/utils/TagsHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/utils/TagsHelper.java b/omniNotes/src/main/java/it/feio/android/omninotes/utils/TagsHelper.java index ac68bb50f2..f53dcab1ff 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/utils/TagsHelper.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/utils/TagsHelper.java @@ -87,8 +87,9 @@ private static boolean mapContainsTag(HashMap tagsMap, Tag tag) public static Pair removeTag(String noteTitle, String noteContent, List tagsToRemove) { String title = noteTitle, content = noteContent; for (Tag tagToRemove : tagsToRemove) { - title = title.replaceAll(tagToRemove.getText(), ""); - content = content.replaceAll(tagToRemove.getText(), ""); + String tagRegex = tagToRemove.getText() + "(\\s)|" + tagToRemove.getText() + "$"; + title = title.replaceAll(tagRegex, ""); + content = content.replaceAll(tagRegex, ""); } return new Pair<>(title, content); }