截取某个字符串的问题。 FileSource = "H:\\资料\\库\\哲学名字术语2.txt"从这个串截取“哲学名字术语”几个字符,就是"\\" 和“.”之间的字符。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 LastIndexOf(".")LastIndexOf("\\") trystring FileSource = "H:\\资料\\库\\哲学名字术语2.txt";string resultStr = "";Match m = Regex.Match(FileSource, @"(?<=\\)[^\\]*?(?=\.)");if(m.Success){ resultStr = m.Value;} or trystring FileSource = "H:\\资料\\库\\哲学名字术语2.txt";string resultStr = FileSource.Substring(FileSource.LastIndexOf("\\")+1,FileSource.LastIndexOf(".")-FileSource.LastIndexOf("\\")-1); System.Io.Path.GetFileNameWithoutExtension(FileSource) System.IO.Path.GetFileNameWithoutExtension(FileSource) FileSource.substring(FileSource.lastIndexOf("\\"));FileSource.substring(1,FileSource.lastIndexOf(".")-1);验证过了啊 这个正则怎么写?速度结贴 VS CTRL+ALT+P 不能调试 帮忙看下正则表达式 求即时通讯系统C#源代码 我在服务器端有一个EXCEL文件,我想在客户弹出一个对话框,问用户是打开还是保存 webservice 操作文件时出现问题。 不改变原来的类,监听属性值的修改,怎么实现? C#绑定数据有趣现象!!! 项目突然出了问题,救急呀! e文window的“网上邻居”是什么? 如何知道数组是否为空。 HttpWebRequest与线程问题
LastIndexOf("\\")
string FileSource = "H:\\资料\\库\\哲学名字术语2.txt";
string resultStr = "";
Match m = Regex.Match(FileSource, @"(?<=\\)[^\\]*?(?=\.)");
if(m.Success)
{
resultStr = m.Value;
}
string resultStr = FileSource.Substring(FileSource.LastIndexOf("\\")+1,FileSource.LastIndexOf(".")-FileSource.LastIndexOf("\\")-1);
FileSource.substring(1,FileSource.lastIndexOf(".")-1);
验证过了啊