@Test
    public void contextLoads() {
        /*String str="this is (Tom) and \"Eric\", this is \"Bruce lee\", he is a chinese, name is \"李小龙\"。";
        Pattern p= Pattern.compile("\"(.*?)\"");
        Matcher m=p.matcher(str);
        while(m.find()){
            System.out.println(m.group());
        }*/


        /*String str="this is [Tom] and , he is a [chinese], name [is]。";
        Matcher mat = Pattern.compile("(?<=\\[)(\\S+)(?=\\])").matcher(str);
        while(mat.find()){
            System.out.println(mat.group());
        }*/


        String filetext = "//[张小名] 25分//[李小花] 43分//[王力] 100分";
        Pattern p = Pattern.compile("\\[(.*?)\\]");//正则表达式,取=和|之间的字符串,不包括=和|
        Matcher m = p.matcher(filetext);
        while(m.find()) {
            System.out.println(m.group(0));//m.group(1)不包括这两个字符
        }
    }

测试以下这三个例子,自己体会