字符串和正则问题 有一个字符串比如“::string str=“33”+“5a”+“3b”+“4c”运行输出为333 aaaaa bbb cccc 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static GetPaddingString(string input){ char paddingChr = input[input.Length-1]; int paddingWidth = Convert.ToInt32(intput.SubString(0, intput.Length - 1)); return new String(paddingChr, paddingWidth);} string temp = "33" + "5a" + "3b" + "4c"; temp = Regex.Replace(temp, @"^\d{2}", "333"); temp = Regex.Replace(temp, @"\d{1}[a]", "aaa"); temp = Regex.Replace(temp, @"\d{1}[b]", "bbb"); temp = Regex.Replace(temp, @"\d{1}[c]", "ccc"); Console.WriteLine(temp); void Main(){ string str="335a3b4c"; str=Regex.Replace(str,@"(\d)([a-zA-Z])",(Match m)=>new string(char.Parse(m.Groups[2].Value),int.Parse(m.Groups[1].Value))); Console.WriteLine(str); //33aaaaabbbcccc} void Main(){ string str="33"+"5a"+"3b"+"4c"; GetString(ref str); Console.WriteLine(str); //33 aaaaa bbb cccc}void GetString(ref string str){ str= Regex.Replace(str,@"(\d)([a-zA-Z])",(Match m)=>" "+new string(char.Parse(m.Groups[2].Value),int.Parse(m.Groups[1].Value)));} C# Winform 看不到网站的代码如何在程序中获得? 在程序1的窗体A上怎么调用API函数来控制程序2的窗体A??? DateTime.TryParse(s, out dt) 关于配置文件的一点疑问~~ 如何去除数值字符串后面 0 ? 如何解决:未能找到任何适合于指定的区域性或非特定区域性的资源 释放内存问题 我想对GridViewd的行标头进行设置,比如显示显示当前行数。怎样实现? 如何把check样式 修改成图片。 c#中打开新窗体的问题 请教一个 系统托盘气球的问题 C# 如何取得网络路径下的文件图标?
{
char paddingChr = input[input.Length-1];
int paddingWidth = Convert.ToInt32(intput.SubString(0, intput.Length - 1));
return new String(paddingChr, paddingWidth);
}
temp = Regex.Replace(temp, @"^\d{2}", "333");
temp = Regex.Replace(temp, @"\d{1}[a]", "aaa");
temp = Regex.Replace(temp, @"\d{1}[b]", "bbb");
temp = Regex.Replace(temp, @"\d{1}[c]", "ccc");
Console.WriteLine(temp);
void Main()
{
string str="335a3b4c";
str=Regex.Replace(str,@"(\d)([a-zA-Z])",(Match m)=>new string(char.Parse(m.Groups[2].Value),int.Parse(m.Groups[1].Value)));
Console.WriteLine(str);
//33aaaaabbbcccc
}
{
string str="33"+"5a"+"3b"+"4c";
GetString(ref str);
Console.WriteLine(str);
//33 aaaaa bbb cccc}
void GetString(ref string str)
{
str= Regex.Replace(str,@"(\d)([a-zA-Z])",(Match m)=>" "+new string(char.Parse(m.Groups[2].Value),int.Parse(m.Groups[1].Value)));
}