用这个字符串
http://sfsdf.com/sdfsdf-sdfsdf/sdf-as.html
我需要获取sdf-as
有了这个
hellow-1/yo-sdf.html
我需要yo-sdf
请您参考如下方法:
这应该得到你想要的:
Regex re = new Regex(@"/([^/]*)\.html$");
Match match = re.Match("http://sfsdf.com/sdfsdf-sdfsdf/sdf-as.html");
Console.WriteLine(match.Groups[1].Value); //Or do whatever you want with the value
这需要在文件顶部使用 using System.Text.RegularExpressions; 才能工作。
