请问这个是按什么拆分字符串?TKS!
str.split(" *?\\+ *?")

解决方案 »

  1.   

    split(String regex) 
              根据给定的正则表达式的匹配来拆分此字符串。
      

  2.   

    俺就是看懂这个正则呀,帮忙解释一下呢,TKS!
      

  3.   

    认识到一点
      
    Reluctant 数量词 
    X?? X,一次或一次也没有 
    X*? X,零次或多次 
    X+? X,一次或多次 
    X{n}? X,恰好 n 次 
    X{n,}? X,至少 n 次 
    X{n,m}? X,至少 n 次,但是不超过 m 次 
    和Greedy数量词的区别.
    真有意思
      

  4.   


    public class Test {
        public static void main(String[] args) {
           String str="str + hell+osfs+ f+ sdfds           +          +dfads";
            String[] strs=str.split(" *?\\+ *?");
            for(String temp : strs){
                System.out.println(temp+" :"+temp.length());
            }
        }
    }有没有问号对+后面的空格处理不一样.