Program
<%
' Written in the previous Full-text retrieval program.
' Original by Bird @dev-club.com
' Email:flybird@dev-club.com
' ie5.5 script engine required
Dim patern
Dim found
Dim str
Dim result
Patern= "(a) | (b) "
Str= "A dog fall in love with A cat." Can you believe? "
Result= ""
Call Getmatchtext (Str,result,false)
Response.Write Result
Sub Getmatchtext (ByRef str,byref Result,isneedtrunc)
' On Error Resume Next
Dim regEx, Match, Matches
Dim tstr
Set regEx = New RegExp ' establishes a regular expression.
Regex.pattern = (patern) ' Set mode.
Regex.ignorecase = True ' Sets whether character case is case-sensitive.
Regex.global = True ' Sets global availability.
Set matches = regex.execute (str) ' performs a search.
If Err.number<>0 Then
Response.Write "Error 1:" & Err.Description
Err.Clear
Exit Sub
End If
If Matches.count <>0 Then
Dim StartIndex
Dim mymatchvalue
Startindex=1
For the match in matches
if (InStr (Str,match.value) >0) Then
If InStr (Str,match.value) -50 >0 Then
STARTINDEX=INSTR (Str,match.value)-50
Else
Startindex=1
End If
Mymatchvalue=match.value
Exit For
End If
Next
If Isneedtrunc Then
Result= (Mid (Str,startindex,strlength (mymatchvalue) +100))
Else
result= (str)
End If
For the match in matches
If not (InStr (result, "<font color=red>" & Match.value & "</font>") >0) Then
Result=replace (Result,match.value, "<font color=red>" & Match.value & "</font>")
End If
Next
Found=true
Else
Found=false
End If
Set regex=nothing
End Sub
%>