zoukankan      html  css  js  c++  java
  • 分割字符串

    #region 分割字符串
     2         /// <summary>
     3         /// 分割字符串
     4         /// </summary>
     5         public static string[] SplitString(string strContent, string strSplit)
     6         {
     7             if (!string.IsNullOrEmpty(strContent))
     8             {
     9                 if (strContent.IndexOf(strSplit) < 0)
    10                     return new string[] { strContent };
    11 
    12                 return Regex.Split(strContent, Regex.Escape(strSplit), RegexOptions.IgnoreCase);
    13             }
    14             else
    15                 return new string[0] { };
    16         }
    17 
    18         /// <summary>
    19         /// 分割字符串
    20         /// </summary>
    21         /// <returns></returns>
    22         public static string[] SplitString(string strContent, string strSplit, int count)
    23         {
    24             string[] result = new string[count];
    25             string[] splited = SplitString(strContent, strSplit);
    26 
    27             for (int i = 0; i < count; i++)
    28             {
    29                 if (i < splited.Length)
    30                     result[i] = splited[i];
    31                 else
    32                     result[i] = string.Empty;
    33             }
    34 
    35             return result;
    36         }
    37         #endregion
    复制代码
  • 相关阅读:
    Postfix邮件
    RAID和LVM磁盘阵列
    CF1400G
    CF1400F
    2020 AC Saber夏季赛 游记
    APIO2018 题解
    2020北京中考游记
    初中数学几何推理大梳理
    CF1373F Network Coverage
    部编人教版初中历史书事件影响/意义汇总
  • 原文地址:https://www.cnblogs.com/zhangxiaolei521/p/5808516.html
Copyright © 2011-2022 走看看