[thelist] Help with a replace loop

Shinji Kuwayama shinji at kuwayama.com
Tue Jun 12 13:53:15 CDT 2001


on 6/12/01 11:59 AM, rudy at r937 at interlog.com wrote:

>> e-mail      a way of sending messages over the Internet
>> Internet    a global network of computers
> 
> um, okay, my trick with the blank is going to fail there too

Yeah, I'm wary of relying on delimiters inside the variables. Taking your
cue, I've done this:

<cfquery name="getTerms" datasource="theDataSource">
    select *
    from Glossary
</cfquery>

<cfloop query="getTerms">
    <cfset varcopy = ReplaceNoCase(varcopy,'#term#','~#term#~',"ALL")>
</cfloop>

<cfloop query="getTerms">
    <cfif FindNoCase('~#term#~',varcopy) is not 0>
        <cfset varcopy = ReplaceNoCase(varcopy,'~#term#~','<a href="http://"
title="#definition#">#term#</a>',"ALL")>
    </cfif>
</cfloop>

This does work. However, the first loop matches terms inside of terms, which
messes things up a little. It gives results like this:

~<a href="http://" title="definition">data</a>base~

Thoughts?

-- 
Shinji Kuwayama
Director, Internet Development
http://www.internetcoach.com/





More information about the thelist mailing list