String str= "N=22539 100016&Nty=1&Ntk=product_rank1&Ntt=&Ntx=mode matchallpartial";去掉"N=22539 100016&",即参数"N",N 的值和分隔符"&".怎么去掉,谢谢!

解决方案 »

  1.   

    Nty=1&Ntk=product_rank1&Ntt=&Ntx=mode matchallpartial你想要的结果是这个吗?
      

  2.   

    I don't know what the style of all the strings, but the code can be used for your example...String[] strArray = str.split("&");String output = "";for (int i=1; i<strArray.length; i++)
      output += strArray[i];
      

  3.   

    对的,就要“Nty=1&Ntk=product_rank1&Ntt=&Ntx=mode matchallpartial ”。replace()不见效阿:(
    其实可以把用连接的方法,可以觉得太笨了 :)
      

  4.   

    谢谢justinavril,是的可以这样做,可是还有更简单的办法吗?
      

  5.   

    String str= "N=22539 100016&Nty=1&Ntk=product_rank1&Ntt=&Ntx=mode matchallpartial";
    str = str.replaceAll("N=([^&]*)&?", "");
    System.out.println(str);
      

  6.   

    public class Test1 {    public static void main(String[] args) {
            String str= "N=22539 100016&Nty=1&Ntk=product_rank1&Ntt=&Ntx=mode matchallpartial"; 
            str = str.replaceAll("N=[^&]*&", "");
            System.out.println(str);
        }
    }
      

  7.   

    int index = str.indexOf("&");
    String newStr = str.substring(index + 1);
      

  8.   


    public class test {
        public static void main(String[] args) {
            String str= "N=22539 100016&Nty=1&Ntk=product_rank1&Ntt=&Ntx=mode matchallpartial"; 
            String str2 = str.replace("N=22539 100016", "");
            System.out.println(str);
            System.out.println(str2);
        }}打印的结果:
    N=22539 100016&Nty=1&Ntk=product_rank1&Ntt=&Ntx=mode matchallpartial
    &Nty=1&Ntk=product_rank1&Ntt=&Ntx=mode matchallpartial
      

  9.   

    String str2 = str.replace("N=22539 100016&", "");
      

  10.   


    return str.replace("N=([^&]*)&?", ""); 
      

  11.   

    public class TString {
    public static void main(String[] args) {
    String str = "N=22539 100016&Nty=1&Ntk=product_rank1&Ntt=&Ntx=mode matchallpartial";
    str = str.replaceAll("N=[^N]*", "");
    System.out.println(str);
    }
    }
      

  12.   

    it's weird ! just now it doesn't work:)非常感谢各位的热情帮助,嗬嗬;
    我觉得substring 正则表达式最简单,谢谢啦:D
      

  13.   

    获取第一个 & 所在位置 offset
    subString(offset + 1);