diff --git a/app/src/main/java/net/gsantner/markor/format/todotxt/TodoTxtTextActions.java b/app/src/main/java/net/gsantner/markor/format/todotxt/TodoTxtTextActions.java index 95682747cc..d8061847fe 100644 --- a/app/src/main/java/net/gsantner/markor/format/todotxt/TodoTxtTextActions.java +++ b/app/src/main/java/net/gsantner/markor/format/todotxt/TodoTxtTextActions.java @@ -388,7 +388,7 @@ private void setDueDate(final int offset) { // Replace due date new ReplacePattern(TodoTxtTask.PATTERN_DUE_DATE, "$1" + newDue + "$4"), // Add due date to end if none already exists. Will correctly handle trailing whitespace. - new ReplacePattern("(\\s)*$", " " + newDue) + new ReplacePattern("\\s*$", " " + newDue) ); }; diff --git a/app/src/main/java/net/gsantner/markor/ui/hleditor/TextActions.java b/app/src/main/java/net/gsantner/markor/ui/hleditor/TextActions.java index ab1e0b502c..8922fbdefc 100644 --- a/app/src/main/java/net/gsantner/markor/ui/hleditor/TextActions.java +++ b/app/src/main/java/net/gsantner/markor/ui/hleditor/TextActions.java @@ -424,8 +424,7 @@ private static void _runRegexReplaceAction(final EditText editor, final List matchEnd search - final String newRegion = replacer.replaceAll(pattern.replacePattern); + final String newRegion = pattern.replaceAll ? replacer.replaceAll(pattern.replacePattern) : replacer.replaceFirst(pattern.replacePattern); text.replace(matchStart + lineStart, matchEnd + lineStart, newRegion); // Change effective selection based on update selEnd += newRegion.length() - oldRegion.length();