Function InstrTblRev(ByVal Start As Integer, ByVal Source As String, _ ByVal Table As String, Optional ByVal Include As Boolean = True, _ Optional ByVal CaseInsensitive As Boolean = False) As Integer Dim pattern As String If Include Then pattern = "[" & Table & "]" Else pattern = "[^" & Table & "]" End If Dim options As Text.RegularExpressions.RegexOptions If CaseInsensitive Then options = Text.RegularExpressions.RegexOptions.IgnoreCase End If Dim re As New Text.RegularExpressions.Regex(pattern, options)
Source = StrReverse(Source) If Start >= 0 And Start < Source.Length Then Start = Source.Length - Start Else Start = 0 End If
Dim ma As Text.RegularExpressions.Match = re.Match(Source, Start) If ma.Success Then Return Source.Length - ma.Index - 1 Else Return -1 End If
End Function |