有一个字符串 String s =“test\one\two/”,如何分割才能得到two

解决方案 »

  1.   

    s.subString(s.lastIndexof("\"),s.indexof("//"));
      

  2.   

    我那句话也不对吧 String s= "test\one\two/"不报编译错误
      

  3.   

    public String substring(int beginIndex,
                            int endIndex)返回一个新字符串,它是此字符串的一个子字符串。该子字符串从指定的 beginIndex 处开始,直到索引 endIndex - 1 处的字符。因此,该子字符串的长度为 endIndex-beginIndex。 
    示例:  "hamburger".substring(4, 8) returns "urge"
     "smiles".substring(1, 5) returns "mile"
     
    参数:
    beginIndex - 起始索引(包括)。
    endIndex - 结束索引(不包括)。