Why do IsMatch and Matcher do not have the same results ?
output
B4X:
Sub Search
Dim toFind As String = "GetCanonicalPath"
Dim pattern As String = "\b"& toFind &"\b"
Dim list As List
list.Initialize
list.AddAll( Array As String( "test", "getCanonicalPath", "GetCanonicalPath", "Private Sub GetCanonicalPath(Path As String) As String"))
For Each line As String In list
'Log( line)
If Regex.IsMatch( pattern, line) Then
Log( "FOUND Regex : "& line)
End If
If grep( pattern, line) Then
Log( "FOUND grep : "& line)
End If
' If line.Contains( toFind) Then
' Log( "FOUND Contains : "& line)
' End If
Next
End Sub
Private Sub grep( pattern As String, Text As String) As Boolean
Dim Matcher1 As Matcher = Regex.Matcher( pattern, Text)
Return Matcher1.Find
End Sub
output
B4X:
FOUND Regex : GetCanonicalPath
FOUND grep : GetCanonicalPath
FOUND grep : Private Sub GetCanonicalPath(Path As String) As String