Re: REReplace to avoid HTML elements
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. That's the \W bits you're using - they're wrong; you want a zero-width word boundary, not a non-word character. Use \b(#Variables.Word#)\b and you wont need to do the workaround. ~| 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:314936 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
Thanks, I will try that out locally and make a note to apply it the next time I am in there since I already initiated the push process to get the changes into place. On Fri, Nov 7, 2008 at 8:03 AM, Peter Boughton [EMAIL PROTECTED] wrote: 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. That's the \W bits you're using - they're wrong; you want a zero-width word boundary, not a non-word character. Use \b(#Variables.Word#)\b and you wont need to do the workaround. ~| 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:314937 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
That's the \W bits you're using - they're wrong; you want a zero-width word boundary, not a non-word character. Use \b(#Variables.Word#)\b and you wont need to do the workaround. Thanks Peter... I'd never used word boundaries... so of course, they don't occur to me when I go to write a regex. :) I'll have to remember that in the future. -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog ~| 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:314944 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
The \b actually did not work, it put the link within the first span element but maybe was how I tested it. I tried: (?![/]sub)(\b)(sub)(\b) as well as (?![/]sub)\b(sub)\b On Fri, Nov 7, 2008 at 10:49 AM, s. isaac dealey [EMAIL PROTECTED] wrote: That's the \W bits you're using - they're wrong; you want a zero-width word boundary, not a non-word character. Use \b(#Variables.Word#)\b and you wont need to do the workaround. Thanks Peter... I'd never used word boundaries... so of course, they don't occur to me when I go to write a regex. :) I'll have to remember that in the future. -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog ~| 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:314947 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
The \b actually did not work, it put the link within the first span element but maybe was how I tested it. I tried: (?![/]sub)(\b)(sub)(\b) as well as (?![/]sub)\b(sub)\b Ah, you need to change your \2 to \1 in your replace part. Since the \b is zero-width, it looks like it wont populate a backreference even when wrapped in parens. Infact, if you wanted, you could go a step further and use \0 along with (?![/]sub)\bsub\b ~| 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:314950 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
REReplace to avoid HTML elements
I have been using REReplace to find key words or group of words within paragraphs and if found to replace those with an HREF. All has been working fine and well until recently when one of those key words became sub and some paragraphs make use of the HTML element SUB. So what I am curious on is how can I adjust the CFSET below to ignore a word if that word is found within and or within / and . cfset word = sub / cfset Output = REReplaceNoCase(Output, (\W)(#Variables.Word#)(\W), \1a href=Display.cfm?Term=#urlencodedformat(Variables.Word)#\2/a\3, one) / -- Aaron Rouse http://www.happyhacker.com/ ~| 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:314913 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
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:314914 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REReplace to avoid HTML elements
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