我正在尝试获取以下标签之间的所有文本,但无法正常工作
If Not String.IsNullOrEmpty(_html) Then
Dim regex As Regex = New Regex( _
".*<entry(?<link>.+)</entry>", _
RegexOptions.IgnoreCase _
Or RegexOptions.CultureInvariant _
Or RegexOptions.Multiline _
)
Dim ms As MatchCollection = regex.Matches(_html)
Dim url As String = String.Empty
For Each m As Match In ms
url = m.Groups("link").Value
urls.Add(url)
Next
Return urls
我已经编写了获取函数以将 html 作为字符串获取。我正在查看 html 敏捷包的示例,但我没有将文件保存为 html 文档
HtmlDocument doc = new HtmlDocument();
doc.Load("file.htm");
foreach(HtmlNode link in doc.DocumentElement.SelectNodes("//a[@href"])
{
HtmlAttribute att = link["href"];
att.Value = FixLink(att);
}
doc.Save("file.htm");
最佳答案
我会使用此软件来帮助您处理正则表达式。
免费 RegExBuilder软件。
关于.net - 正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3970728/