久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      正則表達(dá)式截取字符串的方法技巧

      有這么一段字符串:

      [數(shù)字]字符串

      結(jié)果

      取  a=數(shù)字

           b=字符串

      截取方法1:

        int a = Convert.ToInt32(txt1.Text.Trim().Replace('[', ']').Split(']')[1]);     string b = txt1.Text.Trim().Replace('[', ']').Split(']')[2]; 

      截取方法2:

        string str = "[數(shù)字]字符串";  Regex reg = new Regex(@"  ([^]+)](.*)");  string a= Convert.ToInt32( reg.Match(str).Groups[1].Value);  string b= Convert.ToInt32( reg.Match(str).Groups[2].Value);

      截取方法3

        string tempStr = "[數(shù)字]字符串";   string pattern = @"  ([s§]∗)  ([sS]*)";  Regex re = new Regex(pattern);   string str1 = Regex.Replace(tempStr,pattern,"$1");   string str2 = Regex.Replace(tempStr, pattern, "$2");

        變成數(shù)組怎么寫

          /// <summary>    /// 返回一個(gè)字符串?dāng)?shù)組    /// </summary>    /// <param name="str"></param>    /// <returns></returns>    public string[] ReturnIDAndName(string str)    {          string[] stringArray = new string[2];          Regex reg = new Regex(@"  ([^]+)](.*)");      stringArray[0]= reg.Match(str).Groups[1].Value;      stringArray[1] = reg.Match(str).Groups[2].Value;          return stringArray;    }        /// <summary>    /// 截取字符串編號(hào)    /// </summary>    public int ReturnId(string str)    {      try      {        if (string.IsNullOrEmpty(str))        {          return 0;        }        Regex regex = new Regex("(?<=\[)\d+(?=\])");        Match m = regex.Match(str);        int pid;        if (!m.Success)        {          pid = int.Parse("[" + regex.Match(str).Value + "]");        }        return int.Parse(regex.Match(str).Value);      }      catch      {        return 0;      }    }

      以上就是本文給大家分享的正則表達(dá)式截取字符串的方法技巧,希望大家喜歡。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)