复制代码代码如下:
'替换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 =什么都没有
最终功能