This java example will show how to split a string into an array using a regular expression. First defining a pattern and passing a space will split the character sequence by a space. Once it is split we will write a unit test and validate the elements using hamcrest arrayContaining.
Straight up Java
@Test
public void split_string_with_regex() {
String[] stringSplit = Pattern.compile(" ").split("there is a dog");
assertThat(stringSplit, arrayContaining("there", "is", "a", "dog"));
}