比如:输入字符串2+45+435*34+(3*5)+4 输出2,+,45,+,435即把每个字符都输出来
解决方案 »
- 如何用C#通过nbtstat命令 同时取得 Hostname和Mac Address
- 好像是关于访问器的,类中用private和public分别定义同名变量编译失败
- 急!!!WinForm control在design-time下如何全球化?
- C# form窗体实现用户名和密码验证问题
- 一个我搞不懂的IPAddress构造函数异常,请大家解答~=~
- 为什么我在windows 2003 下不能够利用System.Web.Mail 来发邮件 总是提示SendUsing配置错误
- vs 2005 bt地址,大家一起来加速啊!
- 会者不难.(用户控件问题)将我的代码用指定的方法重写一下.
- 如何得知运行环境的语言是vb 还是c#
- 请大家推荐几本比较有深度的C#书籍
- 长字符串如何换行?
- asp.net中labler控件在前端映射成<span>标签,我想改成<div>标签????????????
char[] num = new char[100];
char[] other = new char[100];
int i = 0;
int j = 0;
foreach (char ch in str)
{
if (Char.IsNumber(ch))
{
num[i++] = ch;
}
else
{
other[j++] = ch;
}
}
char[] num = new char[100];
char[] other = new char[100];
int i = 0;
int j = 0;
foreach (char ch in str)
{
if (Char.IsNumber(ch))
{
num[i++] = ch;
}
else
{
other[j++] = ch;
}
}
public void Disp()
{
for (int i = 0; i < text.Length; i++)
{
//为了看清效果,这里分行输出
Console.WriteLine(text.Substring(i, 1));
}
}
前面的接收字符串的逻辑我就不写了,那很简单.
{
string result=string.Empty;
string temp="";
foreach (char c in express)
{
if (char.IsDigit(c)) temp += c.ToString();
else
{
if (temp != "") result += temp + ",";
result += c.ToString() + ",";
temp = "";
}
}
if (temp != "") result += temp;
return result.TrimEnd(",");
}
List<string> result = new List<string>();
string str = "2+45+435*34+(3*5)+4";
for(int i = 0;i < str.Length; i ++)
{
if (!Char.IsNumber(str[i]))
{
if(chars.Count > 0)
{
result.Add(new string(chars.ToArray()));
chars.Clear();
}
result.Add(str[i].ToString());
}
else
{
chars.Add(str[i]);
}
}按顺序输出result里面的item即可。
{
string result=string.Empty;
string temp="";
foreach (char c in express)
{
if (char.IsDigit(c)) temp += c.ToString();
else
{
if (temp != "") result += temp + ",";
result += c.ToString() + ",";
temp = "";
}
}
if (temp != "") result += temp;
return result.TrimEnd(',');//上面有误,这里要换成单引。。
}
System.Text.RegularExpressions.MatchCollection matchs = regexp.Matches("2+45+435*34+(3*5)+4"); foreach (System.Text.RegularExpressions.Match match in matchs)
{
System.Console.Write(match.Value+",");
}