I'm wondering if anyone has improved the highlight function from thread333-1085319. It doesn't ignore html code (the html breaks if someone searches for "span"). I'd like to use a regexp but don't know how to implement it. Here is the function from that thread:
Thanks
Code:
function highlight(search,andor,text)
temp = text
if search <> "" then
dim RegularExpressionObject
Set RegularExpressionObject = New RegExp
if andor = "or" then
searchStr = split(search," ")
for each item in searchStr
With RegularExpressionObject
.Pattern = "\b"&item&"s?\b"
.IgnoreCase = True
.Global = True
End With
set Matches = RegularExpressionObject.execute(temp)
RegularExpressionObject.IgnoreCase = False
RegularExpressionObject.Global = False
For Each Match in Matches ' Iterate Matches collection.
RegularExpressionObject.Pattern = "\b"&Match.Value&"\b"
temp = RegularExpressionObject.replace(temp,"<#span class='highlight'>"&(Match.Value)&"<#/span>")
i=i+1
Next
next
else
With RegularExpressionObject
.Pattern = "\b"&search&"s?\b"
.IgnoreCase = True
.Global = True
End With
set Matches = RegularExpressionObject.execute(temp)
RegularExpressionObject.IgnoreCase = False
RegularExpressionObject.Global = False
For Each Match in Matches ' Iterate Matches collection.
RegularExpressionObject.Pattern = "\b"&Match.Value&"\b"
temp = RegularExpressionObject.replace(temp,"<#span class='highlight'>"&(Match.Value)&"<#/span>")
i=i+1
Next
end if
end if
temp = replace(temp,"<#span class='highlight'><#span class='highlight'>","<span class='highlight'>")
temp = replace(temp,"<#span class='highlight'>","<span class='highlight'>")
temp = replace(temp,"<#/span><#/span>","<#/span>")
temp = replace(temp,"<#/span>","</span>")
highlight = temp
end function
Thanks