Imports System.Text.RegularExpressions
' Set up the regular expressions we'll use in the loop
Dim A_Regex as Regex = New Regex( _
"[^>]+)>(?.*?)", _
RegexOptions.IgnoreCase)
Dim GutsRegex as Regex = New Regex( _
"\b HREF (?# 'href' attribute )" & _
"\s* = \s* (?# '=' with optional whitespace )" & _
"(?: (?# Value is ... )" & _
" ""(?[^""]*)"" (?# double-quoted string, )" & _
" | (?# or ... )" & _
" '(?[^']*)' (?# single-quoted string, )" & _
" | (?# or ... )" & _
" (?[^'"">\s]+) (?# 'other stuff' )" & _
") (?# )", _
RegexOptions.IgnoreCase OR RegexOptions.IgnorePatternWhitespace)
' Now check the 'Html' Variable . . .
Dim CheckA as Match = A_Regex.Match(Html)
' For each match within . . .
While CheckA.Success
' We matched an tag, so now check for the URL.
Dim UrlCheck as Match = _
GutsRegex.Match(CheckA.Groups("guts").Value)
If UrlCheck.Success
' We've got a match, so have a URL/link pair
Console.WriteLine("Url " & UrlCheck.Groups("url").Value & _
" WITH LINK " & CheckA.Groups("Link").Value)
End If
CheckA = CheckA.NextMatch
End While
-----------------------------------------------------------------------------
Copyright 1997-2024 Jeffrey Friedl