複製代碼代碼如下:
'替換withhighhighhighlightedeplacement(usedStyle)和ProperServescase
publicFunctionHighlight(Strtext,strfind)
dimobjregexp,i,strhighlight
'SplitTheSearchTerMintoanArray
Dimarrfind
arrfind = split(strfind,“”)
'初始ZETHEREDERAREXPRESSICOBJECTTOPERFOMTHESEARZ
Dimomatches,Smatch
setoregexp = newregexp
Oregexp.global = true'ReturnSallMatchestoTheSearchTerm
oregexp.ignorecase = true'caseinsentive
'loopThroughThearRayofSearchTermStofIndMatches
fori = 0toubound(arrfind)
oregexp.pattern = arrfind(i)'setStheSearchPatternString
setomatches = oregexp.execute(strtext)'// persiveStheSearch
foreachMatchinoMUTCHES
'buildthecodeTobeusedtoTohighlightresults
strhighlight =“ <spanclass =”“亮點”>“&match.value&” </span>“
下一個
'替換與搜索WithTheBoveCode的替換
strtext = oregexp.replace(strtext,strhighlight)
下一個
亮點= strtext
setObjregexp =什麼都沒有
最終功能