复制代码代码如下:
'appatternwithhighlightedReplacement(Styleを使用)およびPreservescase
publicFunctionHighlight(strtext、strfind)
dimobjregexp、i、strhighlight
'SplittheSearchtermsIntoAnarray
dimarrfind
arrfind = split(strfind、 "")
'initializetheregularexpressionObjectToperFomTheSearch
dimomatches、smatch
setoregexp = newRegexp
oregexp.global = true'returnsallmatchestotheSearchterm
oregexp.ignorecase = true'caseInsensitive
'loopthroughthearrayOfSearchTermStofIndMatches
fori = 0toubound(arrfind)
oregexp.pattern = arrfind(i) 'setsthesearchpatternstring
setomatches = oregexp.execute(strtext) '// performsthesearch
foreachmatchinomatches
'buildthecodetobeusedtohighlightresults
strhighlight = "<spanclass =" "highlight" ">"&match.value& "</span>"
次
'交換してください
strtext = oregexp.replace(strtext、strhighlight)
次
highlight = strtext
setobjregexp =何も
エンド機能