"Igal" <ig********@gmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
i can't see how this can help me. i'll try to to be more clear.
Interesting. As I understand it you want to be able to highlight the search
words in the body of text that was searched without affecting the case used
by the original text.
>
SearchFor = the search words user typed
EmpJobsText = SQL result with a lot of text
SearchForSp = Split(SearchFor, " ") = this line splits the search words
by the spaces between them
// this begins a loop that runs the number of words user typed.
For i = 0 to Ubound(SearchForSp)
// inside this loop i need to replace words Inside EmpJobsText that =
SearchForSp(i) with SearchForSp(i) but with html tags around it
(<b>SearchForSp(i)</b>)
next
i don't want the replace will be case sensitive.
Assumptions:
Words in SearchFor contain only ASCII alphanumeric characters
Each word is seperated by a single space
Your search finds only whole words.
Dim rgx : Set rgx = New RegExp
rgx.Pattern = "\b(" & Replace(SearchFor, " ", "|") & ")\b"
Creates a pattern which finds any of the search words. It places the found
search word in sub-match $1.
rgx.Global = True
The pattern will be used iteratively untill no further matches are found
rgx.IgnoreCase = True
The case of the search words is not material. Note that it is the text with
it's current case as found in the search text which is placed in sub-match
$1
MsgBox rgx.Replace(EmpJobsText, "<u>$1</u>")
Ok is this where it confused. The MsgBox is simply there since I tested in
VBS. Clearly what you need is:-
EmpJobsText = rgx.Replace(EmpJobsText, "<u>$1</u>")
It replaces each search word with the same word (with it's case preserved)
with the underline mark up. (I was sure you could see how to add you
additional mark up requirements to it).
>