How to parse a string that contains value only needed partially to an arraylist? [closed]

String[] b = a.split(":[^,]+(?:, *)?");

Or:

String[] b = Pattern.compile("[^, ]+(?=:)").matcher(a).results()
                    .map(r -> r.group()).toArray(String[]::new);

Leave a Comment