java中的matches -> 完全匹配

matches是完全匹配。跟matcher不一样, matcher像perl正则, 能匹配到符合的都会返回true, 而这个matches要完全一模一样才行。

 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class test {

    public static void main(String[] args) {
        System.out.println("192".matches("[1][0-9][1-2]"));
        System.out.println("abc".matches("[a-z]{3}"));
        System.out.println("abc".matches("ab"));
    
        
        
    }


}

 

posted on 2017-07-22 05:07  Perl6  阅读(2714)  评论(0编辑  收藏  举报

导航