From 8c78d33f0b293235e18bbc9e38d7fddb8b7b1f22 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 2 Nov 2023 12:53:46 -0400 Subject: [PATCH] Rename to removeAdjacentDuplicates Signed-off-by: Craig Perkins --- .../src/main/java/org/opensearch/common/regex/Regex.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/opensearch/common/regex/Regex.java b/server/src/main/java/org/opensearch/common/regex/Regex.java index 315b86a9b329f..4aac8961e7eec 100644 --- a/server/src/main/java/org/opensearch/common/regex/Regex.java +++ b/server/src/main/java/org/opensearch/common/regex/Regex.java @@ -99,7 +99,7 @@ public static Automaton simpleMatchToAutomaton(String... patterns) { * @param target - The target character to remove duplicates of * @return - string with adjacent duplicates of the target character removed */ - static String removeDuplicates(String str, char target) { + static String removeAdjacentDuplicates(String str, char target) { StringBuilder sb = new StringBuilder(); for (char c : str.toCharArray()) { int size = sb.length(); @@ -121,8 +121,7 @@ static String removeDuplicates(String str, char target) { * @return whether the String matches the given pattern */ public static boolean simpleMatch(String pattern, String str) { - String trimmedPattern = removeDuplicates(pattern, '*'); - return simpleMatch(trimmedPattern, str, false); + return simpleMatch(pattern, str, false); } /** @@ -143,7 +142,8 @@ public static boolean simpleMatch(String pattern, String str, boolean caseInsens pattern = Strings.toLowercaseAscii(pattern); str = Strings.toLowercaseAscii(str); } - return simpleMatchWithNormalizedStrings(pattern, str); + String trimmedPattern = removeAdjacentDuplicates(pattern, '*'); + return simpleMatchWithNormalizedStrings(trimmedPattern, str); } private static boolean simpleMatchWithNormalizedStrings(String pattern, String str) {