It's been a long day, so I may well have missed something, but here we go anyway...
One caveat - this assumes at least semi-valid markup - in so far as no > inside of A opening tag/attributes. (Not impossible to fix, but since it's not valid I can't be bothered going that far right now.) <cffunction name="setHyperlinkRel" returntype="String" output="false"> <cfargument name="LinkCode" type="String"/> <cfargument name="RelValue" type="String"/> <cfargument name="Append" type="Boolean" default="true"/> <cfargument name="Delimiter" type="String" default=","/> <cfset var Head = ListFirst(Arguments.LinkCode,'>')/> <cfset var Tail = ListRest(Arguments.LinkCode,'>')/> <cfset var RelAttr = rematch( '(?ims)\brel=(?:\S+|([''"]).*?)(?=\1(?:\s|$))' , Head )/> <cfif ArrayLen(RelAttr)> <cfif NOT find(RelValue,RelAttr[1])> <cfset Head = replace ( Head , RelAttr[1] , ListAppend( RelAttr[1] , Arguments.RelValue , Arguments.Delimiter ) )/> </cfif> <cfelse> <cfset Head = Head & ' rel="#Arguments.RelValue#"' /> </cfif> <cfreturn Head & '>' & Tail /> </cffunction> <cffunction name="addRelNofollow" returntype="String" output="false"> <cfargument name="InputText" type="String"/> <cfset var Result = Arguments.InputText/> <cfset var NewHyperlink = 0/> <cfset var i = 0/> <cfset var Hyperlinks = rematch( '(?ims)<a[^>]+>.*?</a>' , Arguments.InputText )/> <cfloop index="i" from="1" to="#ArrayLen(Hyperlinks)#"> <cfset NewHyperlink = setHyperlinkRel( Hyperlinks[i] , 'nofollow' ) /> <cfset Result = replace( Result , Hyperlinks[i] , NewHyperlink )/> </cfloop> <cfreturn Result /> </cffunction> <cfset NewContent = addRelNofollow( OldContent ) /> That works on all the various examples I've tried so far - let me know if there's anything missed and I'll update it. Needs ColdFusion 8 or Railo 3 for rematch calls (can do one with Java Regex if people need it working with other engines). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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:317964 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4