0
我想弄清楚最好的方式之前获取/字符在字符串中的所有内容。以下是一些示例字符串。得到一切后斜杠c#
var url = dr.FindElements(By.XPath("//*[@id=\"u_0_3\"]/div/h1/a"));
foreach (var item in url)
{
if (item.GetAttribute("href").ToString().Contains("https://www.facebook.com/"))
{
listBox4.Items.Add("here");
}
}
的href是这样=“http://facebook.com/xxx” 希望xxx,它是用户名想要得到它独自在我的列表框中没有网址的
'项目= I替换(@“http://facebook.com/”,string.Empty);'? – oerkelens
不要使用字符串,创建一个'Uri'实例并在那里使用方法/属性。 – Lee
简单而脏的方式是'string [] strArray = strString.Split('/'); strWantedString = strArray [strArray.Count];' – Gopi