I'm using this function to phrase the text (strDES) for occurrences of words (arrKEYS) and I highlight them using the RegEx.
The problem I have is that it highlight text that is between the HTML tags it created, more specifically the
<span class='spanMATCH'>$1</span>
Is there any way to tell the RegEx to keep highlighting, only text out of the <> tags ?
"Taxes are the fees we pay for civilized society" G.W.
The problem I have is that it highlight text that is between the HTML tags it created, more specifically the
<span class='spanMATCH'>$1</span>
Is there any way to tell the RegEx to keep highlighting, only text out of the <> tags ?
Code:
PRIVATE FUNCTION HIGHLIGHT(strDES, arrKEYS)
Dim regEx, I
Set regEx = New RegExp
FOR I = 0 to Ubound(arrKEYS)
regEx.Global = True
regEx.IgnoreCase = True
'regEx.Pattern = "(\b" & arrKEYS(I) & "[?!, ])" ' REGEX FOR WHOLE WORDS ONLY
regEx.Pattern = "(" & arrKEYS(I) & ")" ' Any occurance of the match
strDES = regEx.Replace(strDES,"<span class='spanMATCH'>$1</span>")
NEXT
Set regEx = Nothing
HIGHLIGHT = strDES
END FUNCTION
"Taxes are the fees we pay for civilized society" G.W.