1
html文字列のアンカーのhref値を抽出できました。今、私が達成したいのは、href値を抽出し、この値を新しいGUIDで置き換えることです。置き換えられたhtml文字列と抽出されたhref値のリストとそれに対応するGUIDの両方を返す必要があります。名前付きグループ正規表現の抽出と置き換え
ありがとうございます。
私の既存のコードは次のようである:
Dim sPattern As String = "<a[^>]*href\s*=\s*((\""(?<URL>[^\""]*)\"")|(\'(?<URL>[^\']*)\')|(?<URL>[^\s]*))"
Dim matches As MatchCollection = Regex.Matches(html, sPattern, RegexOptions.IgnoreCase Or RegexOptions.IgnorePatternWhitespace)
If Not IsNothing(matches) AndAlso matches.Count > 0 Then
Dim urls As List(Of String) = New List(Of String)
For Each m As Match In matches
urls.Add(m.Groups("URL").Value)
Next
End If
サンプルHTML文字列:
<html><body><a title="http://www.google.com" href="http://www.google.com">http://www.google.com</a><br /><a href="http://www.yahoo.com">http://www.yahoo.com</a><br /><a title="http://www.apple.com" href="http://www.apple.com">Apple</a></body></html>
クラップス。事実の後に私はあなたの答えを複製したことに気づいただけです。 +1 :) –