[Solved] Java: split text [duplicate]


You can use Pattern and Matcher:

String input = "Java: split text [duplicate],[description blablablablablabla]";

Pattern pattern = Pattern.compile("\\[(.*?)\\]");
Matcher matcher = pattern.matcher(input);
ArrayList<String> stringList = new ArrayList<String>();

while(matcher.find()) {
    stringList.add(matcher.group(1));
}

//If you just need the results to be stored in an array of Strings anyway.
String[] stringArray = stringList.toArray(new String[stringList.size()]); 

1

solved Java: split text [duplicate]