Java tutorial
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static ArrayList<String> getMatchString(String origin, String pattern, int groupId) { ArrayList<String> datas = new ArrayList<>(); Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(origin); while (m.find()) { datas.add(m.group(groupId)); } return datas; } }