The color of the specified character in the asp flag string is case insensitive.

Source: Internet
Author: User

Common replacement Functions

Copy codeThe Code is as follows: public function HighLight (S, F)
Dim tL, tM, tR, k
TL = ""
TM = ""
TR = S
K = instr (1, tR, F, 1)
Do while k> 0
TL = tL & left (tR, k-1)
TM = mid (tR, k, len (F ))
TL = tL & "<span style = 'color: red'>" & tM & "</span>"
TR = right (tR, Len (tR)-len (F)-k + 1)
K = instr (1, tR, F, 1)
Loop
HighLight = tL & tR
End function
TS = "abcabcabcabcabcabcabca"
TF = "bc"
Response. Write (tS)
Response. Write ("<br/> ")
Response. Write (HighLight (tS, tF ))

Regular Expression

Copy codeThe Code is as follows: Function HighLight (S, F)
Dim regEx
Set regEx = New RegExp
RegEx. IgnoreCase = True
RegEx. Global = True
RegEx. Pattern = "(" & F &")"
HighLight = regEx. Replace (S, "<span style = 'color: red'> $1 </span> ")
End Function
Response. write HighLight ("abcaBcabCaBCabcaBCa", "bc ")
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.