[thelist] Help with a replace loop
sarah
disaster7 at yahoo.com
Tue Jun 12 12:44:03 CDT 2001
I've been playing with some stuff and I can't get it
to work 100%, but I think it's headed in the right
direction.
Basically, what you could do is use varcopy as a list,
using space as the delimiter. Then just loop through
those words individually and check them against each
keyword (which is nice, cause you can check exact
matches rather than doing a find), replace the words
with the link individually, and print them to screen
individually. I think that would be the only way
around such a problem. You have to do each word in
varcopy separately.
Hope that helps,
Sarah
Here's the code I was playing with, it just stupidly
repeats the linked words, I'm sure someone, somewhere
can figure out how to fix that. My mind isn't in the
right place today.
<cfset theString = "i am not quite sure how this is
going to work">
<cfloop index="x" list="#theString#" delimiters=" ">
<cfloop index="keyword" list="quite,sure,going,work"
delimiters=",">
<cfif keyword is x>
<cfset currentWord =
ReplaceNoCase(x,keyword,'<cfoutput><a
href="#keyword#">#keyword#</a></cfoutput>',"ALL")>
<cfoutput>#currentWord#</cfoutput>
<cfelse>
</cfif>
</cfloop>
<cfoutput>#x#</cfoutput>
</cfloop>
> Hi Sarah! The terms are unique; what's happening is
> that terms sometimes
> appear inside the #definition# of other terms. So if
> the query returned:
>
> Terms: Definitions:
> e-mail a way of sending messages over the
> Internet
> Internet a global network of computers
>
> The code produces this:
>
> <a href="[url]" title="a way of sending messages
> over the <a href="[url]"
> title="a global network of
> computers">Internet</a>">E-mail</a> is the most
> popular part of the Internet.
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/
More information about the thelist
mailing list