So I have a loop in regex,
List<String> data = new ArrayList<>();
List<String> inputData = // String array
Pattern pattern = Pattern.compile(regex);
inputData.forEach(i -> {
Matcher matcher = pattern.matcher(i);
while(matcher.find()) {
data.add(matcher.group().trim());
}
});
Now data will have an array of strings like this,
data = ['text', 'text2', 'text3', 'text4', 'text5', 'text6']
I want to divide this array of strings into a fixed size of 3.
data = [['text', 'text2', 'text3'], ['text4', 'text5', 'text6']]