Case | highlights | keywords | functions
here is the function source code: <% Function Takeout (patrn,string1,colors) ' Extract search keyword matching text Dim regEx, Match, matches, TT ' create variable. Set regEx = New RegExp ' establishes a regular expression. Regex.pattern = Patrn ' Set mode. Regex.ignorecase = True ' Sets whether case sensitive. Regex.global = True ' Sets global availability. Set matches = Regex.execute (string1) ' performs a search. For the Match in matches ' traverses the matches collection. Retstr = retstr & Match.value & "" Next
Retstr = Trim (RETSTR) If InStr (Retstr, "") >0 Then For TT = 0 To UBound (split (Retstr, "")) string1 = replace (String1,split (Retstr, "") (TT), "<font color=" "&colors&" ">" &split (Retstr, "") ( TT) & "</font>") Next Else string1 = replace (string1,retstr, "<font color=" "&colors&" ">" &RetStr& "</font>") End If Takeout = string1 End Function Response.Write Takeout ("Joekoe", "Joekoe Joek bilingual Edition", "Red") Function Highlight (Strcontent,keyword) ' tag highlighting keyword Dim RegEx Set regex=new REGEXP Regex.ignorecase =true ' case-insensitive Regex.global=true Dim Arraykeyword,i Arraykeyword = Split (keyword, "") ' multiple keywords separated by spaces For i=0 to Ubound (Arraykeyword) Regex.pattern= "(" &arraykeyword (i) & ")" Strcontent=regex.replace (strcontent, "<font color=red>$1</font>") Next Set regex=nothing Highlight=strcontent End Function Response.Write Highlight ("Joekoe Joek bilingual Edition", "Joekoe") %> |