就是78.34 这样的数字不能分开截取的 
  第一个abcdefgh78.34 那字符个数就13个了
  所以就把它移到第二个来

解决方案 »

  1.   

    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    namespace ConsoleApplication1
    {
        class Class1
        {
            public static void Main()
            {
                List<string> items = ConvertToList("abcdefgh78.34abcdefgh");
                foreach (string item in items)
                {
                    System.Console.WriteLine(item);
                }            System.Console.ReadLine();        }        public static List<string> ConvertToList(string content)
            {
                List<string> items = null;            if (content.Length > 0)
                {
                    items = new List<string>();
                }            string temp = null;
                string temp2 = null;            for (int i = 0; i < content.Length; i++)
                {
                    temp2 = temp + content[i].ToString();
                    if (IsCanUse(temp2))
                    {
                        if (temp2.Length % 10 != 0)
                        {
                            temp += content[i].ToString();
                        }
                        else
                        {
                            temp += content[i].ToString();
                            items.Add(temp);
                            temp = temp2 = null;
                        }
                    }
                    else
                    {
                        items.Add(temp);
                        temp = content[i].ToString();
                        temp2 = null;
                    }
                }
                if (temp != null)
                {
                    items.Add(temp);
                }            return items;
            }        public static bool IsCanUse(string item)
            {
                return 
                    Regex.Match(item, @"^[a-zA-Z]{1,10}$").Success ||
                    Regex.Match(item, @"^[\d]{1,10}$").Success ||
                    Regex.Match(item, @"^[\d]{1,10}\.\d{1,9}$").Success ||
                    Regex.Match(item, @"^\d\S{1,8}[^\d]$").Success;
            }    }
    }
      

  2.   

    运行结果abcdefgh
    78.34abcde
    fgh
      

  3.   


    你把字符串改下ab78.34cdefghabcdefgh
     结果就变成
       ab
       78.34cdefg
       habcdefgh 了其实我要的结果应该是   ab78.34cde
       fghabcdefg
       h
      

  4.   

            String str = "abcdefgh78.34abcdefgh";        Int32 length = str.Length;        List<String> list = new List<String>();
            while (true)
            {
                if(str.Length <= 10)
                {
                    list.Add(str);
                    break;
                }
                else if (str[9] >= '0' && str[9] <= '9')
                {
                    int i;
                    for (i = 8; i >= 0; i--)
                    {
                        if (!(str[i] >= '0' && str[i] <= '9') && str[i] != '.')
                            break;
                    }                if (i == 8)
                    {
                        if (str.Length > 10 && !(str[10] >= '0' && str[10] <= '9') && str[10] != '.')
                        {
                            list.Add(str.Substring(0,10));
                            str = str.Substring(10);
                        }                    if (str.Length > 11 && (str[11] >= '0' && str[11] <= '9') && str[10] == '.')
                        {
                            list.Add(str.Substring(0,9));
                            str = str.Substring(9);
                        }
                    }
                    else
                    {
                        list.Add(str.Substring(0,i + 1));
                        str = str.Substring(i + 1);
                    }
                }
                else if (str[9] == '.')
                {
                    if (str.Length > 10 && str[8] > '0' && str[8] < '9' && str[10] > '0' && str[10] < '9')
                    {
                        int i;
                        for (i = 7; i >= 0; i--)
                        {
                            if (!(str[i] >= '0' && str[i] <= '9'))
                                break;
                        }                    list.Add(str.Substring(0, i + 1));
                        str = str.Substring(i);
                    }
                    else
                    {
                        list.Add(str.Substring(0, 10));
                        str = str.Substring(10);
                    }
                }
                else
                {
                    list.Add(str.Substring(0, 10));
                    str = str.Substring(10);
                }
            }        foreach (String s in list)
            {
                Console.WriteLine(s);
            }