字符串问题!!! 例子就不给你了,附带MSDN里有和这个类似的例子 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用正则表达式匹配@"\s+"代码如下,已经调试过 string cutText = 预设值; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\s+"); System.Text.RegularExpressions.MatchCollection match = regex.Matches(cutText); int stringLen = match.Count+1; string[] s = new string [stringLen]; int len = 0; for(int i=0;i<match.Count;i++) { len = i== 0?match[i].Index - len:match[i].Index - match[i-1].Index - match[i-1].Value.Length; s[i] = cutText.Substring(0,len); len = len +match[i].Value.Length; cutText = cutText.Substring(len); } s[stringLen-1] = cutText;结果在 s[] 里面 觉得大概可以这么做string strTemp = urString.tolower();string strResult = "";//保存结果for(int i=0;i<urString.length;i++){if(strTemp[i] > 'a' and strTemp[i] < 'z')strResult += strTemp[i];} 我觉得你这个问题,可以用strng.split 方法先把空格和标点以外的字符取出来,再进行合并,这样要简单些。如下:using System;class Class1{ static void Main(string[] args) { string s1="sdhj sdkf ??;' fgd;' ! df"; string delimStr=" ?;'!"; char[] delimter=delimStr.ToCharArray(); string[] split =null; split=s1.Split(delimter); string s2=null; foreach(string str in split) { s2=s2+str; } Console.WriteLine(s2); }} 楼主的意思是不是只要取出里面的字符啊?是的话,,string strTemp = YourString;string strResult = "";//保存结果for(int i=0;i<urString.length;i++){if(strTemp[i] > 'a' and strTemp[i] < 'z' || strTemp[i] > 'A' and strTemp[i] < 'Z'))strResult += strTemp[i];} 接口问题 关于Treeview中删除多个节点的问题 关于Arraylist的问题 大家帮帮忙,看这个问题怎么解决 用vs2005写个windows服务,没有执行,不知道为什么,请知道的指点一下 100分啦!关于对数据库操作的问题!! C#里面如何生成在一定范围内的double值? 著名的诺顿磁盘医生NDD32和诺顿碎片整理程序在windows server 2003中不能正常使用了,实在太遗憾了,太 我又落后了...... 问个关于 异步回调AsyncCallback 与 后台处理BackgroundWorker 区别的问题 请问怎样向编辑框控件显示一个字符串的值 数据新建问题(无法保存)
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\s+");
System.Text.RegularExpressions.MatchCollection match = regex.Matches(cutText);
int stringLen = match.Count+1;
string[] s = new string [stringLen];
int len = 0;
for(int i=0;i<match.Count;i++)
{
len = i== 0?match[i].Index - len:match[i].Index - match[i-1].Index - match[i-1].Value.Length;
s[i] = cutText.Substring(0,len);
len = len +match[i].Value.Length;
cutText = cutText.Substring(len);
}
s[stringLen-1] = cutText;结果在 s[] 里面
string strTemp = urString.tolower();
string strResult = "";//保存结果
for(int i=0;i<urString.length;i++)
{if(strTemp[i] > 'a' and strTemp[i] < 'z')
strResult += strTemp[i];
}
如下:
using System;class Class1
{
static void Main(string[] args)
{
string s1="sdhj sdkf ??;' fgd;' ! df";
string delimStr=" ?;'!";
char[] delimter=delimStr.ToCharArray();
string[] split =null;
split=s1.Split(delimter);
string s2=null;
foreach(string str in split)
{
s2=s2+str;
}
Console.WriteLine(s2);
}
}
是的话,,string strTemp = YourString;
string strResult = "";//保存结果
for(int i=0;i<urString.length;i++)
{if(strTemp[i] > 'a' and strTemp[i] < 'z' || strTemp[i] > 'A' and strTemp[i] < 'Z'))
strResult += strTemp[i];
}