解决方案 »
- 求元方来解决这个问题
- 有谁做过word2007插件开发?
- ArrayList 数组问题
- 求助高人帮我看看我的C#代码线程调用控件的问题
- 谁有通用的短信猫动态库(可用于西门子、WAVECOM等GSM模块的)?
- 高手们看看
- .net2005真是麻烦不断,怎么办啊!大家看看这个错误!急!急!
- 请问如何比较两个image类型的对象所表示的图片是否相同?
- 在页面上单击一个Button, 返回到服务器时,依次会执行哪些事件(常用的)
- 一个c++如何转成c#的简单问题?
- vs2005中TableCell里面如何增加HTML语言
- [c#]DataTable的Compute方法,对时间的过滤在个别电脑中无法转换为时间,求解决办法。
商户编号 308350149000080 清算日期 20101227 生成日期 20101229
第 1页
终端编号 交易时间 账号 发卡行 交易金额 交易手续费 结算金额 系统检索号 跟踪号 渠道 交易类型
──── ───── ───────── ─── ─────── ───── ─────── ────── ─── ── ────
30808013 1228105552 6229023431678105 03090000 41,200.00 -412.00 40,788.00 000001000019 137133 pos 消费 终端编号 交易笔数 交易金额 手续费 结算金额
30808013 1 41,200.00 -412.00 40,788.00
小计 1 41,200.00 -412.00 40,788.00 交易类型 交易笔数 交易金额 手续费 结算金额
消费 1 41,200.00 -412.00 40,788.00
小计 1 41,200.00 -412.00 40,788.00
你也已做的是string[] strs=str.Split(' ');
//
int cnt=strs.Length;
for(int i=0;i<cnt;i++){strs[i]=strs[i].Trim();}
//
int cnt=strs.Length;
List<string> list=new List<string>();
for(int i=0;i<cnt;i++)
{
if(!string.IsNullOrEmpty(strs[i].Trim()))
{
list.Add(strs[i].Trim());
}
}
string[] aaa = System.Text.RegularExpressions.Regex.Split(text, @"[ ]+"); //去字符串中所有(此方法无法除首尾空格)空格
//@"[ ]+" //[]中为删除的可选字符
using System.Text;
class test
{
static void Main()
{
string text="你好 zhlin3415058 能 否 解 决 你的问题";//首尾中有空格,个数不确定
text=text.Trim();//删除首尾空格
//去字符串中所有(此方法无法除首尾空格)空格
string[] aaa = System.Text.RegularExpressions.Regex.Split(text, @"[ ]+");
//去字符串中所有(此方法无法除首尾空格)空格
//@"[ ]+"
//[]中为删除的可选字符
text = aaa[0];
for (int i = 1; i < aaa.Length; i++)
{
text = text + " " + aaa[i];
}
Console.WriteLine(text);
}
}
程序输出:
你好 zhlin3415058 能 否 解 决 你的问题
// listValue[10] 要处理的字符串值 空字符串过滤1:
listValue[10].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries)空字符串过滤2:
System.Text.RegularExpressions.Regex.Split(listValue[10], @"[ ]+")两种方法都很简便~