Hi,

I am building a search enginee and I would like to hightlight the keywords
or phrase in the search similiar to Google.
For one or several keywords are no problem. They are loaded into an array
and iterate through with a replace(str, keyword, "<b>" & keyword & "</b>").

My question is how I can do something similar with a phrase within quotes
and one or several keywords?
ex: "fuelcell batteries for car" energy hydro
and have those hightligted in a result text.

Any ideas,

Thanks in advance
Christian

Re: Hightlight a phrase with replace() by W

W
Mon Jan 02 11:59:02 CST 2006

The syntax for the replace command is:

Replace (string,find, replacewith[,start[,count[,compare]]])

To do what you want to do use the optional values of start, count and
compare in the following manner:
Set start = 1 (default = 1, the beginning of the string).
Set count = 1 (default = -1, which means replace all) so you only
replace them 1 at a time.
Set compare = 0 (default is 0, which performs a binary compare).
Set find = Chr(34) which is the command to replace the ANSI code for a
double quote to a character.

Based on the above here is a code sample:

Before executing the following two lines String1 would look like "fuelcell
batteries for car" energy hydro

string1 = replace(string1, chr(34),"<b>",1,1,0)
string1 = replace(string1, chr(34),"</b>",1,10)

After executing the two lines above String1 would look like <b>fuelcell
batteries for car</b> energy hydro

Hope this helps.



"Christian Perthen" <abracadabara@dontreplytothisaddress.com> wrote in
message news:eqJE3xYDGHA.528@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I am building a search enginee and I would like to hightlight the keywords
> or phrase in the search similiar to Google.
> For one or several keywords are no problem. They are loaded into an array
> and iterate through with a replace(str, keyword, "<b>" & keyword &
> "</b>").
>
> My question is how I can do something similar with a phrase within quotes
> and one or several keywords?
> ex: "fuelcell batteries for car" energy hydro
> and have those hightligted in a result text.
>
> Any ideas,
>
> Thanks in advance
> Christian
>
>
>



Re: Hightlight a phrase with replace() by W

W
Mon Jan 02 12:34:46 CST 2006

OPPS!

I missed the last comma in the 2nd replace it should be string1 =
replace(string1, chr(34),"</b>",1,1,0)

Also, if you had the possibility of multiple quoted strings in a single
string you could replace the two lines with:

while instr(string1,chr(34))
string1 = replace(string1, chr(34),"<b>",1,1,0)
string1 = replace(string1, chr(34),"</b>",1,1,0)
wend


"W C Hull" <substitute1stInitial2ndInitialLastName51@hotmaill.com> wrote in
message news:%23hE60Y8DGHA.2872@TK2MSFTNGP14.phx.gbl...
> The syntax for the replace command is:
>
> Replace (string,find, replacewith[,start[,count[,compare]]])
>
> To do what you want to do use the optional values of start, count and
> compare in the following manner:
> Set start = 1 (default = 1, the beginning of the string).
> Set count = 1 (default = -1, which means replace all) so you only
> replace them 1 at a time.
> Set compare = 0 (default is 0, which performs a binary compare).
> Set find = Chr(34) which is the command to replace the ANSI code for a
> double quote to a character.
>
> Based on the above here is a code sample:
>
> Before executing the following two lines String1 would look like "fuelcell
> batteries for car" energy hydro
>
> string1 = replace(string1, chr(34),"<b>",1,1,0)
> string1 = replace(string1, chr(34),"</b>",1,10)
>
> After executing the two lines above String1 would look like <b>fuelcell
> batteries for car</b> energy hydro
>
> Hope this helps.
>
>
>
> "Christian Perthen" <abracadabara@dontreplytothisaddress.com> wrote in
> message news:eqJE3xYDGHA.528@TK2MSFTNGP09.phx.gbl...
>> Hi,
>>
>> I am building a search enginee and I would like to hightlight the
>> keywords
>> or phrase in the search similiar to Google.
>> For one or several keywords are no problem. They are loaded into an array
>> and iterate through with a replace(str, keyword, "<b>" & keyword &
>> "</b>").
>>
>> My question is how I can do something similar with a phrase within quotes
>> and one or several keywords?
>> ex: "fuelcell batteries for car" energy hydro
>> and have those hightligted in a result text.
>>
>> Any ideas,
>>
>> Thanks in advance
>> Christian
>>
>>
>>
>
>