Skip to content

Commit

Permalink
Remove unused method
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Nov 8, 2023
1 parent 7037090 commit 5b93003
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
17 changes: 0 additions & 17 deletions server/src/main/java/org/opensearch/common/regex/Regex.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,6 @@ public static Automaton simpleMatchToAutomaton(String... patterns) {
return Operations.union(automata);
}

/**
*
* @param str - The input string to remove adjacent duplicate characters from
* @param target - The target character to remove duplicates of
* @return - string with adjacent duplicates of the target character removed
*/
static String removeAdjacentDuplicates(String str, char target) {
StringBuilder sb = new StringBuilder();
for (char c : str.toCharArray()) {
int size = sb.length();
if (size == 0 || c != target || sb.charAt(size - 1) != c) {
sb.append(c);
}
}
return sb.toString();
}

/**
* Match a String against the given pattern, supporting the following simple
* pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,4 @@ public void testSimpleMatch() {
assertFalse("[" + pattern + "] should not match [" + matchingString + "]", Regex.simpleMatch(pattern, matchingString));
}
}

public void testRemoveDuplicates() {
assertEquals("*", Regex.removeAdjacentDuplicates("***", '*'));
assertEquals("*abc*", Regex.removeAdjacentDuplicates("**abc**", '*'));
assertEquals("a*b*c*", Regex.removeAdjacentDuplicates("a*b**c****", '*'));
assertEquals("*abc", Regex.removeAdjacentDuplicates("****abc", '*'));
assertEquals("*", Regex.removeAdjacentDuplicates("*".repeat(100), '*'));
}
}

0 comments on commit 5b93003

Please sign in to comment.