复制代码代码如下:
'replacespatternwithhightedreplacement (باستخدام style) و preservescase
PublicFunctionHighlight (Strtext ، Strfind)
dimobjregexp ، أنا ، strhighlight
'splittheSearchtermsintoAnarray
dimarrfind
arrfind = انقسام (strfind ، "")
'initializetheregularexpressionoBjectToperfomThesearch
dimomatches ، smatch
setoregexp = newregexp
oregexp.global = true'returnsallMatchestOteSearchTerm
oregexp.ignorecase = true'caseinsitive
'loopthroughTheArrayofSearchTermstofIndMatches
fori = 0toubound (arrfind)
oregexp.pattern = arrfind (i) 'setSTheSearchPatternString
setomatches = oregexp.execute (strtext) '// performsthesearch
foreachmatchinomatches
'BuildTheCodetobeusedToHightresults
strhighlight = "<spanclass =" "Almission" ">" & match.value & "</span>"
التالي
'ReplaceMatchesFromThesearchWithTheAboveCode
strtext = oregexp.replace (strtext ، strhighlight)
التالي
تسليط الضوء = strtext
setObJregexp = لا شيء
الوظيفية