我有这么一个字符串auth=0&service=SUCC&verfiy_rlt=03&photo=YES&photot=1&photor=/photos
 我想把=号后面的值取出来放到a数组中,请问代码怎么写

解决方案 »

  1.   

    <script language="JavaScript">
    <!--
    function splitParam(value){
    var arr = value.split("&");
    var d = [];
    for(var i=0; i<arr.length; i++){
    d[d.length] = arr[i].split("=");
    }
    return d;
    }var f = splitParam('auth=0&service=SUCC&verfiy_rlt=03&photo=YES&photot=1&photor=/photos');
    alert(f[0][0]);
    alert(f[0][1]);
    //-->
    </script>
      

  2.   

    string b = @"auth=0&service=SUCC&verfiy_rlt=03&photo=YES&photot=1&photor=/photos";
    string [] a = b.Split('=');
    for (int i=0;i<a.Length;i++)
        Console.WriteLine(a[i]);
      

  3.   

    trystring test = "auth=0&service=SUCC&verfiy_rlt=03&photo=YES&photot=1&photor=/photos";
    string[] a = System.Text.RegularExpressions.Regex.Split(test, @"&[^=]*=");
      

  4.   

    wangsaokui(无间道III(终极无间)C#MVP)今天升的?再次恭喜
      

  5.   

    string[] roleRightArray = System.Text.RegularExpressions.Regex.Split(auth, @"[=]+");
      

  6.   

    用正则吧。
            private void Form1_Load(object sender, EventArgs e)
            {
                this.label1.Text = "";
                Regex re = new Regex(@"\w*=");
                string[] a = re.Split("auth=0&service=SUCC&verfiy_rlt=03&photo=YES&photot=1&photor=/photos");
                foreach (string m in a)
                {
                    this.label1.Text += m.ToString() + "\n";
                } 
            }
      
    ---------------------------------------------
    EMail:[email protected] 请给我一个与您交流的机会!
      

  7.   

    放两个控件TextBox3和TextBox4Page_Load里代码如下:
    string tempStr="auth=0&service=SUCC&verfiy_rlt=03&photo=YES&photot=1&photor=/photos";
    this.TextBox3.Text=tempStr;
    char[] a=tempStr.ToCharArray();
    int count=0;
    foreach(char b in a)
    {
    if(b.ToString()=="=")
    {
    count+=1;
    }
    }
    if(count!=0)
    {
    string[] str=new string[count];
    string temp="";
    int i=0;
    do
    {
    tempStr=tempStr.Substring(tempStr.IndexOf("=")+1);
    if(tempStr.IndexOf("&")>0)
    {
    temp=tempStr.Substring(0,tempStr.IndexOf("&"));
    }
    else
    {
    temp=tempStr.Substring(0,tempStr.Length);
    }
    str[i]=temp;
    i++;
    }
    while(tempStr.IndexOf("=")>0); for(int j=0;j<count;j++)
    {
    this.TextBox4.Text=this.TextBox4.Text+str[j].ToString();
    }
    }运行应该是楼主要的结果