Here's one approach using regular expressions:
String input = "[a05, [a24, a23], [b08, b09], c26, c30, a22, a13, m06]";
// Strip outer [...]
String content = input.substring(1, input.length() - 1);
List<String> parts = new ArrayList<>();
Matcher m = Pattern.compile("\\[.*?\\]|[^\\[, ]+").matcher(content);
while (m.find()) {
parts.add(m.group());
}
parts.forEach(System.out::println);
Output:
a05
[a24, a23]
[b08, b09]
c26
c30
a22
a13
m06
Regex break down:
\[.*?\]
-- something on the form [...]
|
-- or
[^\[, ]+
-- one or more characters that are not [
, ,
or space.
Perhaps I took your example too literally. Feel free to expand your example with more complicated cases if the above doesn't work out.
A note on regular expressions
Note that regular expressions are quite limited in what they can express, and only suitable when input is fairly predictable. Should you discover the need for arbitrary nesting of brackets [...[...]...]
or similar cases, you have to do more work. The "next step" would probably be to loop / parse input "by hand" or to write a context free grammar and use a parser generator.