Pattern p = Pattern.compile("正则表达式");Matcher m = p.matcher("预匹配的字符串");if(m.matches()) { m.group(1); //匹配第1项 m.group(2); //匹配第2项}