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"));
    
        
        
    }


}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-03-04
  • 2021-08-05
  • 2022-12-23
  • 2021-12-31
  • 2021-10-15
猜你喜欢
  • 2021-09-26
  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
相关资源
相似解决方案