Ha! That would be great, but search engines won't see that which is the
point really.

Using that PHP regex you pointed to:

<cfsavecontent variable="html">
Goto <a href="http://google.com";>No</a> now!
and turning it into:
Goto <a href="http://google.com"; rel="nofollow">~Yes</a> now!
</cfsavecontent>

<cfoutput>

<pre>#HTMLEditFormat(html)#</pre>

<cfset re =
"<[\s]*a[\s]*href=[\s]*[\""\']?([\w.-]*)[\""\']?[^>]*>(.*?)<\/a>">

<cfset matches = REMatch(re, html)>

<cfdump var="#matches#">

<cfloop array="#matches#" index="match">
        <p>#HTMLEditFormat(match)#</p>
        <cfif NOT FindNoCase("nofollow", match)>
                <cfset newLink = Replace(match, ">", " rel=""nofollow""",
"ONE")>
                <cfset html = ReplaceNoCase(html, match, newLink)>
        </cfif>
</cfloop>

<pre>#HTMLEditFormat(html)#</pre>

Not as nice as a one hit RegEx but seems to get the job done :)

Adrian

> -----Original Message-----
> From: Andy Matthews [mailto:li...@commadelimited.com]
> Sent: 14 January 2009 15:27
> To: cf-talk
> Subject: RE: nofollow regex
> 
> Does it have to be a server side solution? jQuery would make this a
> snap:
> 
> $(document).ready(function(){
>       $('a[href^="http"]').attr('rel','nofollow');
> });
> 
> <a href="/somepage.html">This is an internal link</a>
> <br><br>
> <a href="http://google.com";>And this is an external link, with no
> follow</a>
> 
> 
> -----Original Message-----
> From: Jeff Becker [mailto:jpbec...@yahoo.com]
> Sent: Wednesday, January 14, 2009 8:58 AM
> To: cf-talk
> Subject: nofollow regex
> 
> Hey folks,
> Since I got no love in the RegEx forum, I'm hoping to post here to get
> a
> little more eyeballs on the question I'm struggling over.
> 
> I'm looking for a working rel="nofollow" regex to modify links.
> 
> For example:
> 
> Goto <a href="http://google.com";>Google</a> now!
> and turning it into:
> Goto <a href="http://google.com"; rel="nofollow">Google</a> now!
> 
> The best solution I've found so far is:
> http://www.sitecritic.net/articleDetail.php?id=242  , but this is a PHP
> solution.  Any ideas on converting this to Coldfusion?
> 
> The PHP solution covers a lot of scenarios (extra attributes, single
> quotes
> instead of double quotes) etc.. so that would be ideal.
> 
> Thanks!



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:317925
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to