Fork me on GitHub

正表达式获取路径中的文件名称

    string url = @"D:\Program Files\Tencent\QQMusic\myf_&iles.text";
    private string GetFileName(string FullName)
{
Regex re = new Regex(@"\\[^\\]*$");

Match ma = re.Match(FullName);
if (ma.Success)
{
re = new Regex(@"\\|(\.[a-z]{3,4})", RegexOptions.IgnoreCase);
return re.Replace(ma.Value,"");
}
else
return "";
}
posted @ 2012-02-23 22:19  逍遥メ风  阅读(205)  评论(0)    收藏  举报