Merge pull request #11407 from Teica/master
BAEL-5195 Modified the regex pattern
This commit is contained in:
commit
35ea11e64f
|
@ -17,7 +17,7 @@ public class MultipleDelimitersSplitUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenString_whenSplittingByMultipleDelimitersWithRegEx_thenStringSplit() {
|
public void givenString_whenSplittingByMultipleDelimitersWithRegEx_thenStringSplit() {
|
||||||
String example = "Mary;Thomas:Jane-Kate";
|
String example = "Mary;Thomas:Jane-Kate";
|
||||||
String[] names = example.split(";|:|-");
|
String[] names = example.split("[;:-]");
|
||||||
String[] expectedNames = new String[]{"Mary", "Thomas", "Jane", "Kate"};
|
String[] expectedNames = new String[]{"Mary", "Thomas", "Jane", "Kate"};
|
||||||
Assertions.assertEquals(4, names.length);
|
Assertions.assertEquals(4, names.length);
|
||||||
Assertions.assertArrayEquals(expectedNames, names);
|
Assertions.assertArrayEquals(expectedNames, names);
|
||||||
|
@ -38,7 +38,7 @@ public class MultipleDelimitersSplitUnitTest {
|
||||||
String example = "Mary;Thomas:Jane-Kate";
|
String example = "Mary;Thomas:Jane-Kate";
|
||||||
String[] expectedArray = new String[]{"Mary", "Thomas", "Jane", "Kate"};
|
String[] expectedArray = new String[]{"Mary", "Thomas", "Jane", "Kate"};
|
||||||
Iterable<String> expected = Arrays.asList(expectedArray);
|
Iterable<String> expected = Arrays.asList(expectedArray);
|
||||||
Iterable<String> names = Splitter.on(Pattern.compile(";|:|-")).split(example);
|
Iterable<String> names = Splitter.on(Pattern.compile("[;:-]")).split(example);
|
||||||
Assertions.assertEquals(4, Iterators.size(names.iterator()));
|
Assertions.assertEquals(4, Iterators.size(names.iterator()));
|
||||||
Assertions.assertIterableEquals(expected, names);
|
Assertions.assertIterableEquals(expected, names);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class MultipleDelimitersSplitUnitTest {
|
||||||
String example = "Mary;Thomas:Jane-Kate";
|
String example = "Mary;Thomas:Jane-Kate";
|
||||||
String[] expectedArray = new String[]{"Mary", "Thomas", "Jane", "Kate"};
|
String[] expectedArray = new String[]{"Mary", "Thomas", "Jane", "Kate"};
|
||||||
Iterable<String> expected = Arrays.asList(expectedArray);
|
Iterable<String> expected = Arrays.asList(expectedArray);
|
||||||
Iterable<String> names = Splitter.onPattern(";|:|-").split(example);
|
Iterable<String> names = Splitter.onPattern("[;:-]").split(example);
|
||||||
Assertions.assertEquals(4, Iterators.size(names.iterator()));
|
Assertions.assertEquals(4, Iterators.size(names.iterator()));
|
||||||
Assertions.assertIterableEquals(expected, names);
|
Assertions.assertIterableEquals(expected, names);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue