Exemplo n.º 1
0
        /// <summary>
        /// Finds the index of a string to split it at.
        /// </summary>
        /// <param name="text">Text to split.</param>
        /// <param name="maxChars">Maximum number of chars allowed in the primary string.</param>
        /// <returns>The index of a string to split it at.</returns>
        public static int FindIndexToSplitAt(string text, int maxChars)
        {
            // Split at either the first acceptable split character
            for (var i = maxChars; i > Math.Max(0, maxChars - 8); i--)
            {
                if (SplitChars.Contains(text[i]))
                {
                    return(i);
                }
            }

            // No valid split characters were found, so just split at the max length
            return(maxChars);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 是否为规定的分隔符
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 private bool IsSplitChar(char c)
 {
     return(SplitChars.Contains(c));// c == '/' || c == ' ' || c == ':';
 }