Пример #1
0
 public static string[] Split(string Expression, string Delimiter /* = " " */, int Limit /* = -1 */, StringCompareMethod Compare /* = 0 */)
 {
     string[] textArray1;
     try
     {
         int num2;
         if ((Expression == null) || (Expression.Length == 0))
         {
             return(new string[1] {
                 ""
             });
         }
         if (Limit == -1)
         {
             Limit = Expression.Length + 1;
         }
         if (Delimiter == null)
         {
             num2 = 0;
         }
         else
         {
             num2 = Delimiter.Length;
         }
         if (num2 == 0)
         {
             return(new string[1] {
                 Expression
             });
         }
         textArray1 = SplitHelper(Expression, Delimiter, Limit, (int)Compare);
     }
     catch (Exception exception1)
     {
         throw exception1;
     }
     return(textArray1);
 }
Пример #2
0
        public static string Replace(string Expression, string Find, string Replacement, int Start /* = 1 */, int Count /* = -1 */, StringCompareMethod Compare /* = 0 */)
        {
            string text1;

            try
            {
                if (Count < -1)
                {
                    throw new ArgumentException("Count 0", "Replace");
                }
                if (Start <= 0)
                {
                    throw new ArgumentException("Start 0", "Replace");
                }
                if ((Expression == null) || (Start > Expression.Length))
                {
                    return(null);
                }
                if (Start != 1)
                {
                    Expression = Expression.Substring(Start - 1);
                }
                if (((Find == null) || (Find.Length == 0)) || (Count == 0))
                {
                    return(Expression);
                }
                if (Count == -1)
                {
                    Count = Expression.Length;
                }
                text1 = Join(Split(Expression, Find, Count + 1, Compare), Replacement);
            }
            catch (Exception exception1)
            {
                throw exception1;
            }
            return(text1);
        }