没明白lz的意思,但是看2楼的话感觉lz可以看看编译原理的词法分析部分,根据状态机的不同来判断当前字符的种类

解决方案 »

  1.   

    split()
    把你要分割的字符都编程模式字符,比如说空格,and,or等
      

  2.   

    满足楼主第一次拆分,第二次比较麻烦,而且没什么好的解决方法;string strSource = "((fnumber='0515'and fnumber > '0517')or(fname<>'默认'))";
                string tmpSource = strSource.ToLower();
                strSource = strSource.ToLower();
                string[] keys ={ "and", "or" ,"(",")","<",">","=","'","\""};
                for (int i = 0; i < keys.Length; i++)
                {
                    if(keys[i].Length>1)
                    tmpSource = tmpSource.Replace(keys[i], "" + keys[i] + "\n");
                }            //char[] tmpArr =System.Environment.NewLine.ToCharArray();
                char[] tmpArr = { '\n'};
                string[] strResult = tmpSource.Split(tmpArr);
                Console.WriteLine("第一次拆分结果:");
                for (int i = 0; i < strResult.Length; i++)
                {
                    Console.WriteLine(strResult[i]);
                }