日期:2014-05-19  浏览次数:20992 次

获取字符串中的最右边字符
现在有字符串:/我的文档/FILES/TEX/CSDN/

如何和获取最右边“CSDN”呢?



------解决方案--------------------
string a = "/我的文档/FILES/TEX/CSDN/ ";
string[] b = a.Split(StringSplitOptions.RemoveEmptyEntries);
b[b.Length-1]即是
------解决方案--------------------
string str1 = "/我的文档/FILES/TEX/CSDN/ ";
char[] chr = new char[1] { '/ ' };
string[] sss = str1.Split(chr, StringSplitOptions.RemoveEmptyEntries);
MessageBox.Show(sss[sss.Length - 1]);

sss[sss.Length - 1]为CSDN



------解决方案--------------------
Regex.Match( "/我的文档/FILES/TEX/CSDN/ ",@ "\w+(?=[/]?)$ ").Value
------解决方案--------------------
MessageBox.Show(System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName( "/我的文档/FILES/TEX/CSDN/ ")));