Use KTM Format Locator / Regex Flavor to perform string matching. This is useful when wanting to match how KTM performs regex searches within format locators.
Public Function IsRegexMatch(ByVal strRegex As String, ByVal strTest As String, ByVal bWholeWord As Boolean, ByVal bIgnoreCase As Boolean, ByVal bIgnoreBlanks As Boolean) As Boolean
OutputDebugString "Scansation.IsRegexMatch"
OutputDebugString "Scansation.strRegex: " & CStr(strRegex)
OutputDebugString "Scansation.strTest: " & CStr(strTest)
OutputDebugString "Scansation.bWholeWord: " & CStr(bWholeWord)
OutputDebugString "Scansation.bIgnoreCase: " & CStr(bIgnoreCase)
OutputDebugString "Scansation.bIgnoreBlanks: " & CStr(bIgnoreBlanks)
Dim fd As CscRegExpLib.CscFormatDefinition
Dim floc As New CscRegExpLib.CscFormatLocator
Dim strResult As String
' This Function uses the Ktm format locator / regex flavour to perform regex matching
' Usage: IsRegexMatch(strPattern, oLine.Text)
On Error GoTo Error_Handler
Set fd=floc.FormatDefinitions.Add(strRegex)
fd.Enabled=True
fd.FormatType=RegularExpression
fd.WholeWord = bWholeWord
fd.IgnoreCase = bIgnoreCase
fd.IgnoreBlanks = bIgnoreBlanks
strResult = floc.TestString(strTest)
If strResult <> "" Then
IsRegexMatch = True
Else
IsRegexMatch = False
End If
OutputDebugString "Scansation.IsRegexMatch: " & CStr(IsRegexMatch)
Exit Function
Error_Handler:
IsRegexMatch = False
End Function