Keyword class feature. Replaces the passed-in string as an expression following the SQL statement where keyword:
Word search [For example: Xiaoming]
Phrase Search
Every word in a phrase will be retrieved
For example: Xiao Qiang 1 nickname 1 small powerful small cockroach
Logical Search
Supports the and and OR operators.
For example: Xiaoming and Xiao Qiang
Compound Condition:
For example: (Small Ming or Xiao Ming) and (Xiao Qiang or Xiao Qiang)
For example: (Small Ming Or nickname) and Xiao Qiang
For example: ROOT1 and (Cantonese Or Peking people)
-----------------------------------------------------------
Class createquerystring
Public Objreg
Public Intstart
Public Strfield
Private ObjNode2
Private StrText
Public Property Let QueryString (strvalue)
StrText = Lcase (strvalue)
End Property
Private Sub Class_Initialize ()
Set Objreg = new REGEXP
Strfield = "(title + article)"
End Sub
Private Sub Class_Terminate ()
Set Objreg = Nothing
End Sub
Public Default Function GetText ()
Dim Blnres
Dim Strsky
With Objreg
. IgnoreCase = True
. Global = True
. Pattern = "\s"
Blnres =. Test (StrText)
End With
If (not blnres) Then
Intstart = 2
GetText = Strfield & "Like '%" & strText & "%"
Else
Objreg.pattern = "\sand|\sor"
Blnres = Objreg.test (StrText)
If Blnres Then
Strsky = Check ()
If Strsky = False Then
GetText = Wahaha ()
Else
GetText = Strsky
End If
Else
GetText = Wahaha ()
End If
End If
End Function
Private Function Wahaha ()
Dim Strter
Dim Strlikes
Dim strors
Dim Stri
Dim Objre
Strter = ""
Strlikes = "or (" & Strfield & "Like '%"
strors = "%")
Objreg.pattern = "(\s*\s)"
Set Objre = Objreg.execute (StrText)
For each stri in Objre
Strter = strter & strlikes & Stri & Strors
Next
Wahaha = Mid (Strter, 4)
Intstart = 3
End Function
Private Function Checkyes (Strmode, intcount)
Dim ObjNode1
Objreg.pattern = Strmode
Set objNode1 = Objreg.execute (StrText)
If Objnode1.count < 1 Then
Checkyes = True
Else
Set objNode2 = objNode1 (0)
If ObjNode2.subMatches.Count < intcount Then
Checkyes = True
End If
End If
End Function
Private Function Orand ()
Dim strsss
Dim STRCCC
Dim STRAAA
Dim a143
Dim I
Dim OBJN
Dim Blntru
Dim BLNBBB
Strsss = "(" & Strfield & "Like '%"
STRCCC = "%")
STRAAA = ""
N1 = 0
Blntru = True
BLNBBB = True
Objreg.pattern = "(\s*\s)"
Set Objn = Objreg.execute (StrText)
a143 = objn.count-1
If (Objn.item (a143) = "and") Or (Objn.item (a143) = "or") Then
Orand = False
Exit Function
End If
For all I in OBJN
If Blntru Then
If (i <> "and") and (I <> "or") Then
Blntru = False
STRAAA = straaa & strsss & I & STRCCC
Else
BLNBBB = False
Exit for
End If
Else
If (i = "and") Or (i = "or") Then
Blntru = True
STRAAA = straaa & I
Else
BLNBBB = False
Exit for
End If
End If
Next
If (not blnbbb) Then
Orand = False
Else
Orand = straaa
Intstart = 4
End If
End Function
Private Function Check ()
Dim RE
Dim Re1
Dim Re2
Dim Re3
Dim Str
Dim str1
Dim A1
Dim A2
Dim A3
Dim A4
str = Strfield & "like"%
str1 = "%"
With Objreg
. Pattern = "^\ (. +\) \s (and|or) \s"
Re =. Test (StrText)
. Pattern = "\s (and|or) \s\ (. +\) $"
Re3 =. Test (StrText)
End With
If Re and Re3 Then
If Checkyes (\s*\s) (\bor\b|\band\b) (\s*\s) (and|or) \ (\s*\s) (\bor\b|\band\b) (\s*\s) \) $ ", 6 Then
Check = False
Else
With ObjNode2
A1 =. Submatches (0)
A2 =. Submatches (2)
a3 =. Submatches (4)
a4 =. Submatches (6)
Check = "(& str & A1 & str1 &" "&. Submatches (1) &" "& Str & A2 & str1 &") "&_
. Submatches (3) & "(" & Str & A3 & str1 & "" &. Submatches (5) & "" & Str & A4 & STR1 & ")"
Intstart = 5