In Java 9, you can now use Matcher#results()
to get a Stream<MatchResult>
which you can use to get a list/array of matches.
import java.util.regex.Pattern;
import java.util.regex.MatchResult;
String[] matches = Pattern.compile("your regex here")
.matcher("string to search from here")
.results()
.map(MatchResult::group)
.toArray(String[]::new);
// or .collect(Collectors.toList())