I have some String
objects that I need to split into an array of substrings at the locations of differing consecutive characters.
My Input/Output should look like this:
"AAAA" -> ["AAAA"]
"AAAABBB" -> ["AAAA", "BBB"]
"ABBCCC" -> ["A", "BB", "CCC"]
I want to be able to write a line of code like this:
String[] charRuns = str.split(regex);
Where str
is the input and charRuns
is the output, but what should the value of regex
be?