find()


//find() 寻找符合 regexp 的子字符串,寻找到的可能有多个
    public static void test1(){
        Pattern compile = Pattern.compile("<.*?>");
        Matcher matcher = compile.matcher("RUNOOB-菜鸟教程

"); matcher.find(); System.out.println(matcher.group()); // matcher.find(); System.out.println(matcher.group()); //

} public static void test3(){ Pattern compile = Pattern.compile("<.*?>"); Matcher matcher = compile.matcher("RUNOOB-菜鸟教程

"); while (matcher.find()){ System.out.println(matcher.group()); } // //

}