Right now I have collection of substrings that match the pattern. I want to add these filtered substrings to an arraylist.
Right now have this:
Pattern reg = Pattern.compile("\\*");
String result = reg.splitAsStream("A*B*C*D*E*F*G*A*B*C*D*E*F*A*B*C*D*E*F*G*H")
.filter(role -> role.matches("A"))
.map(String::trim)
.collect(Collectors.joining(","));
System.out.println(result);
I want to add the printed out result which is all the A into a arraylist I need help with adding it to arraylist.