Thanks Peter, I got to talking to Isaac Dealey this evening about this since he had helped out a while back on this particular project. He mentioned what I need is a lookahead in the regex. After a few tries this is what we ultimately came up with this: "(?![</]#Variables.Word#)(\W)(#Variables.Word#)(\W)"
The only downside that we found is if the word is at the very end or beginning of the paragraph. So I will prepend and append a period to the paragraph then run the regex and then pull out the periods. Wish I had clued into that because maybe one of my attempts earlier today would have worked had my test data not had the word at the very end of the paragraph with no period after it. On Thu, Nov 6, 2008 at 1:13 PM, Peter Boughton <[EMAIL PROTECTED]> wrote: > >I have been using REReplace to find key words or group of words within > >paragraphs and if found to replace those with an HREF. > > > The following code works. > (I haven't yet decided whether it's entirely the best way though...) > > > <cfset Content = ListToArray(Content,'>')/> > > <cfloop index="i" from="1" to="#ArrayLen(Content)#"> > <cfif ListLen(Content[i],'<') GT 1> > <cfset Segment = ListFirst(Content[i],'<')/> > <cfset word = "sub"/> > > <cfset Segment = linkifyText( Segment , Word , > 'Display.cfm?Term='&UrlEncodedFormat(Word) ) /> > > <cfset Content[i] = Segment & '<' & > ListRest(Content[i],'<')/> > </cfif> > </cfloop> > > <cfset Content = ArrayToList(Content,'>')/> > > > > <cffunction name="linkifyText" returntype="String" output="false"> > <cfargument name="Text" type="String"/> > <cfargument name="Word" type="String"/> > <cfargument name="Target" type="String"/> > > <cfreturn rereplace(Arguments.Text,'\b#Arguments.Word#\b','<a > href="#Arguments.Target#">\0</a>','all')/> > </cffunction> > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314925 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4