写时是针对英文的,也没测试输入中文是啥情况.不过中文的情况应该比处理起英文来要简单一点才对. 说明如下: 1. 被<>包含的关键字不会被替换 2. 在<a </a>内部的关键字不会被替换. 此外,还可能有些BUG.LinkKeyWord 1' link key word 2 function LinkKeyword(bIgnoreCase, MainStr, sNeedReplace, sReplaceWith) 3 dim sResult 4 5 Dim objRegExp 6 Set objRegExp = New Regexp 7 objRegExp.IgnoreCase = bIgnoreCase 8 objRegExp.Global = True 9 objRegExp.Pattern = "\b" & sNeedReplace & "\b(?![\w ]*</a>|>)"10 sResult = objRegExp.Replace(MainStr, sReplaceWith)11 Set objRegExp = Nothing12 13 LinkKeyword = sResult14 end function