Skip to content

Commit

Permalink
- r better support for splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsEckart committed Mar 4, 2024
1 parent 49e544f commit 1e28726
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
Expand Down Expand Up @@ -125,10 +124,14 @@ public ReplaceUseCase(String startingString, String find, String replace, String
public void testSplitting()
{
var expected = """
1a2aa3aa -> [1, 2, , 3, ]
1a2aa3a -> [1, 2, , 3]
1a2aa3 -> [1, 2, , 3]
""";
ParseInput.from(expected).verifyAll(s -> Arrays.toString(StringUtils.splitt(s, "a")));
1a2aa3, a -> [1, 2, , 3]
1ś2śś3, ś -> [1, 2, , 3]
1a2aa3a, a -> [1, 2, , 3]
1ś2śś3ś, ś -> [1, 2, , 3]
1a2aa3aa, a -> [1, 2, , 3, ]
1ś2śś3śś, ś -> [1, 2, , 3, ]
""";
ParseInput.from(expected).withTypes(String.class, String.class)
.verifyAll((i, p) -> Arrays.toString(StringUtils.splitt(i, p)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ public static String[] splitt(String input, String pattern)
{
if (input.endsWith(pattern))
{
input = input + " ";
String ending = "ś".equals(pattern) ? "š" : "ś";
input = input + ending;
String[] splitted = input.split(pattern, -1);
return ArrayUtils.getSubsection(splitted, 0, splitted.length - 1);
}
Expand Down

0 comments on commit 1e28726

Please sign in to comment.