In this configuration, we need to implement keyword case-insensitive search and highlight display using ASP Regular Expression Processing. See the following Code :
Copy code The Code is as follows: <%
Function takeout (patrn, string1, colors)
'Extract search keyword match text
Dim RegEx, match, matches, and tt' create variables.
Set RegEx = new Regexp 'to create a regular expression.
RegEx. pattern = patrn 'setting mode.
RegEx. ignorecase = true' is used to set Case sensitivity.
RegEx. Global = true' to set global availability.
Set matches = RegEx. Execute (string1) 'to execute the search.
For each match in matches 'traverses the matches set.
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 bilingual edition", "Red ")
Function highlight (strcontent, keyword) 'indicates the highlighted 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 ", "joekoe ")
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.