如:
你好
sfa10你cc
sfds
s001
001以上都合要求,请教如何书写?

解决方案 »

  1.   

    import java.util.regex.*;
    public class TestString { /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
             String s= "sfa10你cc";
             Pattern pa = Pattern.compile("\\w*[\u4e00-\u9fa5]*");
             Matcher ma = pa.matcher(s);
             while(ma.find()){
              System.out.print(ma.group());
             }
    }}这样就可以都匹配了!
      

  2.   

    不过没有必要Mather.group()吧,
    因为那时不符合Pattern的!
      

  3.   

    \u4e00-\u9fa5 请问下这个什么意思那
      

  4.   

    To:
    interhanchi(Stallman'fans)但我不要匹配 汉字,字母,数字以外的呢,如标点符号不要
      

  5.   

    这样才对:
    ^[\u4e00-\u9fa5\\w.@]{1,20}