' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Collections
Imports System.Text.RegularExpressions

Class MainClass
    Private Shared valid As ArrayList = New ArrayList(New String() {"b", "i"})
    Public Shared Sub Test(ByVal s As String)
        Dim res1 As MatchCollection = Regex.Matches(s, "(?:<)([^/>][^>]*)(?:>)")
        Dim i As Integer
        For i = 0 To res1.Count - 1
            If Not valid.Contains(res1(i).Groups(1).Value) Then
                Console.WriteLine(s + " - contains invalid start tag")
            End If
        Next
        Dim res2 As MatchCollection = Regex.Matches(s, "(?:</)([^>]+)(?:>)")
        For i = 0 To res2.Count - 1
            If Not valid.Contains(res2(i).Groups(1).Value) Then
                Console.WriteLine(s + " - contains invalid end tag")
            End If
        Next
    End Sub
    Public Shared Sub Main(ByVal args As String())
        Test("Dette her er <b>OK</b> text")
        Test("Dette her <a href='http://www.eksperten.dk/'>link</a> er ikke OK")
    End Sub
End Class 
