Such an abstract split does not exist as a default as far as I know.
The basic way you would go about achieving this, would be first to do the regular split as you said, which gave the result.
array[0] = cat
array[1] = feline
array[2] = house
Then you could loop through the array
and check for the different things.
ArrayList<String> animals = new ArrayList<String>();
ArrayList<String> lives = new ArrayList<String>();
for (int i = 0; i < array.length; i++) {
if (array[i].equalsIgnoreCase("cat") || array[i].equalsIgnoreCase("dog")) {
animals.add(array[i]);
}
else if (array[i].equalsIgnoreCase("house") || array[i].equalsIgnoreCase("zoo")) {
lives.add(array[i]);
}
}
Then you would of course do that for all the cases you have. It's a pretty complex way to do it, though really simple to understand.
Edit
To achive what you asked in the comments, you could do something like this.
ArrayList<String> animals = new ArrayList<String>();
ArrayList<String> lives = new ArrayList<String>();
for (int i = 0; i < array.length; i += 5) {
animals.add(array[i]);
lives.add(array[i + 1]);
}
Then the + 1
for selecting the index in the array would of course depend on the index from the splitted String
.