2 dimensionelt array
Jeg har 2 functioner.1 der parse billedkilde fra en html-streng
og 1 der parser alt-tekster.
Jeg vil gerne have det ud i et 2dimensionelt array således
array(0, 0) = "billedkilde.gif"
array(1, 0) = "alt-tekst"
osv...
Nogen der kan/vil hjælpe mig?!?!
De 2 functioner:
Public Function ParseAlt(ByVal strHTML As String) As String
On Error Resume Next
Dim rRegEx As Regex
Dim mMatch As Match
Dim aMatch As New ArrayList()
Dim n As Integer
rRegEx = New Regex("img.*alt\s*=\s*(?:""(?<1>[^""]*)""|(?<1>\S+))", RegexOptions.IgnoreCase Or RegexOptions.Compiled)
mMatch = rRegEx.Match(strHTML)
While mMatch.Success
Dim sMatch As String
sMatch = mMatch.Groups(1).ToString
aMatch.Add(sMatch)
mMatch = mMatch.NextMatch()
End While
ListBox2.Items.Clear()
For n = 0 To aMatch.Count
ListBox2.Items.Add(aMatch(n))
Next
End Function
Public Function ParseImg(ByVal strHTML As String) As String
On Error Resume Next
Dim rRegEx As Regex
Dim mMatch As Match
Dim aMatch As New ArrayList()
Dim n As Integer
rRegEx = New Regex("img.*src\s*=\s*(?:""(?<1>[^""]*)""|(?<1>\S+))", RegexOptions.IgnoreCase Or RegexOptions.Compiled)
mMatch = rRegEx.Match(strHTML)
While mMatch.Success
Dim sMatch As String
sMatch = mMatch.Groups(1).ToString
aMatch.Add(sMatch)
mMatch = mMatch.NextMatch()
End While
ListBox1.Items.Clear()
For n = 0 To aMatch.Count
ListBox1.Items.Add(aMatch(n))
Next
End Function
