import java.util.regex.*; public class Gxjun{ public static void main(String args[]) { Pattern p; //模式对象 Matcher m; //匹配对象 String regex = "(http://|www)\56?\\w+\56{1\\w+\56{1}\\p{Alpha}+}"; p =Pattern.compile(regex); String s="新浪:www.sina.c…
Matcher.group是针对()来说的,group(0)就是指的整个串,group(1) 指的是第一个括号里的东西即匹配的第一个子表达式,group(2)指的第二个括号里的东西即匹配的第二个子表达式. 例如: public class TestMatcher { public static final String STR_PATTERN = "(\\d{3,5})([a-z]{2})"; public static void main(String[] args) { Strin…