Dim sr As New IO.StreamReader("[b]SourceFileName[/b]")
Dim sw As New IO.StreamWriter("[b]TargetFileName[/b]")
Dim rx As New System.Text.RegularExpressions.Regex("[b]PatternYouAreLookingFor[/b]")
Dim s As String = sr.ReadToEnd
sr.Close()
sw.Write(rx.Matches(s).Count)
sw.Close()
sr = Nothing
sw = Nothing
rx = Nothing