Honesty Rocks! truth rules.

[.net]matchall Function

HOME      >>       Programming

CheckProgs

Public Function MatchAll(ByVal strSource As String, ByVal strStart As String, ByVal strEnd As String) As String() Dim strSearch As String Dim ctlRegEx As MatchCollection strSearch = Regex.Escape(strStart) & "(?<text>(\r\n)?.*?(\r\n)?)" & Regex.Escape(strEnd) If Regex.IsMatch(strSource, strSearch, RegexOptions.IgnoreCase) Then ctlRegEx = Regex.Matches(strSource, strSearch, RegexOptions.IgnoreCase) Else Return Nothing End If Dim strResult(ctlRegEx.Count - 1) As String Dim i As Long For i = 0 To ctlRegEx.Count - 1 strResult(i) = ctlRegEx.Item(i).Groups("text").Captures(0).ToString Next Return strResult End Function