博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# 根据空格数截取
阅读量:4519 次
发布时间:2019-06-08

本文共 1834 字,大约阅读时间需要 6 分钟。

#region --根据空格数截取                    string temp = ""; int k = 0; int jc = 0;                    //循环截取                    int[] rules1 = { 7, 6 };                    while (!sr.EndOfStream)                    {                        for (int i = 0; i < strTest.Length - 1; i++)                        {                            string s = strTest.Substring(i, 1).Trim(); //截取当前字符                            string s2 = strTest.Substring(i + 1, 1).Trim();//截取后一个字符                            temp = temp + s;                            //判断当前字符为最后一个字符                            if (string.IsNullOrEmpty(s)) //判断当前字符串为空时候                            {                                k++; //记录空格数                                if (jc >= rules1.Length) //字符串长度过长时候,终止                                {                                    break;                                }                                if (k == rules1[jc])                                {                                    jc++;                                    result += temp + "\t";                                    temp = string.Empty;                                    k = 0;                                }                            }                            if (i == strTest.Length - 2)                            {                                result += temp + "\r\n"; //最后一个                                temp = string.Empty;                                jc = 0;                                break;                            }                        }                        strTest = sr.ReadLine();                        if (strTest.Contains("日期"))                        {                            break;                        }                    }                    #endregion

 

转载于:https://www.cnblogs.com/enych/p/9412095.html

你可能感兴趣的文章
衰减学习率真的有用吗?
查看>>
ORACLE 建库过程总结
查看>>
Ogre1.8.1 Basic Tutorial 6 - The Ogre Startup Sequence
查看>>
构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(36)-文章发布系统③-kindeditor使用...
查看>>
c# Winform 开发分屏显示应用程序
查看>>
canvas刮奖
查看>>
qt下拖放(一)
查看>>
Linux后台运行python程序并输出到日志文件
查看>>
HTML的语义化和一些简单优化
查看>>
jQuery基础教程
查看>>
Spring 在xml文件中配置Bean
查看>>
poj1611(简答并查集)
查看>>
基于scap的服务器安全基线核查设计与实现
查看>>
NFS 安装与配置
查看>>
javascript 模拟滚动 隐藏滚动条
查看>>
深度探索C++对象模型读书笔记(2)
查看>>
Linux下不停止服务,清空nohup.out文件
查看>>
C++11 Intro - Thread Id
查看>>
帝国CMS操作类型一览表
查看>>
spring boot开发环境搭建
查看>>