字符串为
ser=53.11.1.2;upp=vc;ddb=sls8;dwp=123456
如何分别取得
ser,upp,ddb,dwp的值,谢谢大家

解决方案 »

  1.   

    按;spilt,得到是一个数组.
    =后就是值了.自己处理一下.
      

  2.   

    我给 正则的方法
    ]
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;namespace ConsoleApplication56
    {
        class Program
        {
            static void Main(string[] args)
            {
                string str = "ser=53.11.1.2;upp=vc;ddb=sls8;dwp=123456";
                Regex reg = new Regex(@"(\w+)=");
                for (int i = 0; i < reg.Matches(str).Count; i++)
                {
                    Console.WriteLine(reg.Matches(str)[i].Groups[1].Value);
                }
            }
        }
    }
      

  3.   

    定义字符串数组分割
       string str = "ser=53.11.1.2;upp=vc;ddb=sls8;dwp=123456";
                string[] arr = str.Split(';');
                for (int i = 0; i < arr.Length;i++ )
                {
                    Response.Write(arr[i]);
                }
      

  4.   

    定义字符串数组分割
       string str = "ser=53.11.1.2;upp=vc;ddb=sls8;dwp=123456";
                string[] arr = str.Split(';');
                for (int i = 0; i < arr.Length;i++ )
                {
                    Response.Write(arr[i]);
                }
      

  5.   

    定义字符串数组分割
       string str = "ser=53.11.1.2;upp=vc;ddb=sls8;dwp=123456";
                string[] arr = str.Split(';');
                for (int i = 0; i < arr.Length;i++ )
                {
                    Response.Write(arr[i]);
                }
      

  6.   


    我这个 你可以 随便 取值
    自己定义一个 数组就好了 保存 
    string[] a;
      

  7.   

    把2楼的改了改~但是要求每一句都得有";"才行,看来还是用split比较好~    protected void Page_Load(object sender, EventArgs e)
        {
            string str = "ser=53.11.1.2;upp=vc;ddb=sls8;dwp=123456;"; 
            Regex reg = new Regex(@"=(.+?);"); 
            for (int i = 0; i < reg.Matches(str).Count; i++) 
            {
                Response.Write(reg.Matches(str)[i].Groups[1].Value + " ");
            } 
        }
      

  8.   

    能不能直接取值
    如ser=53.11.1.2,就是不通过循环取值.一句就可以.