为什么后面一定要加\\S*啊,我把matches("1\\d{1}\\S*")
改成matches("1\\d+\\S*")也是正确的,晕,前面不是已经匹配了吗?

解决方案 »

  1.   

    Pattern p = Pattern.compile("1\\d");//1+一位数字
    Matcher m = p.matcher("11::123::13");
    while(m.find()){
      System.out.println(m.group());
    }这会印出:
    11
    12
    13
      

  2.   

    另外,matches是判断整个字符串是否匹配。Java doc中是这样描述的:Attempts to match the entire input sequence against the pattern.If the match succeeds then more information can be obtained via the start, end, and group methods. 
    Returns:
    true if, and only if, the entire input sequence matches this matcher's pattern
      

  3.   

    St0ne82() 兄,那我的
    matches("1\\d+")应该反回true的呀,为什么不是呢