字符串截取的问题 类似a_b_c_d_e_d_的字符串我要取得a_b_c_d_e_就是去掉最后的字母和_ 望指点一下,_之间的字符数是不固定的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SUBSTR(字符,0,LENGTH(字符)-2) string aa;aa = aa.Replace("_", "");再去掉最后的字母 得到字符的长度 string str = "sddsfd"; str.Substring(0,str.Length-2) string str = "a_b_c_d_e_d_";string temp = str.Substring(0, str.LastIndexOf("_"));str = temp.Substring(0, temp.LastIndexOf("_") + 1); string str1 = "a_b_c_d_e_f_g_h_";Label1.Text = str1.Substring(0,(str1.Length-2));这样就行.如果还要去掉所有的 _ .那就 Replace("_", "") 一样就行了. string a="a_b_c_d_e_d_";a=Regex.Replace(a,"(?<=_)[^_]+_$",""); lovefootball的方法可以,之前的做法是用string.split形成数组再连接,感觉太麻烦了 c#控制台程序中输入数字出错 关于VAR的问题,十分感谢 C#如何往sql数据库中插入/读取richtext内容? xslt foreach 实现i++ c# winform中 ,如何遍例 TabControl 中的 tabpages的title c# winform怎么在没有创建的控件上引发事件,请高手指教 rsa如何使用第三方的公钥加密? 这种类型的TreeView怎么做? 奇怪的问题 来看看 大家帮忙看看,怎么回事? 关于FolderBrowserDialog的问题 关于子父窗体的问题
aa = aa.Replace("_", "");
再去掉最后的字母
string str = "sddsfd";
str.Substring(0,str.Length-2)
string temp = str.Substring(0, str.LastIndexOf("_"));
str = temp.Substring(0, temp.LastIndexOf("_") + 1);
Label1.Text = str1.Substring(0,(str1.Length-2));
这样就行.如果还要去掉所有的 _ .那就 Replace("_", "") 一样就行了.
a=Regex.Replace(a,"(?<=_)[^_]+_$","");