pf » Auto-Linking Comments

Auto-Linking Comments

coldfusion

To avoid comment spam, my blog comments are displayed as plain text. However urls to other entries on my blog are often posted to in the comments. So I wrote a simple regular expression to create hyperlinks out of them:

REReplaceNoCase(comments.comment, 
	"(http://www\.petefreitag\.com/[^[:space:]]+)",
	"<a href=""\1"">\1</a>", 
	"ALL")

If you want this to work with or without the www you can use something like this for the regular expression:

(http://w*\.?petefreitag\.com/[^[:space:]]+)


Related Entries
10 people found this page useful, what do you think?

Trackback Address: 395/BB0952BD2BAD1FD2492011E7D41C5A13
On 06/24/2005 at 12:17:05 PM MDT forgetfoo wrote:
1
now that's pretty damn useful! thx for post it :)

[OT]

you wouldnt happen to know how they have and can display the content in different languages over at MXNA, would ya?

http://weblogs.macromedia.com/mxna/UserPreferences.cfm

On 06/24/2005 at 12:46:03 PM MDT Pete Freitag wrote:
2
Thanks...

I think the other languages on MXNA are blogs that are actually written in those languages. I could be mistaken perhaps Christain Cantrell or Mike Chambers will read this and can comment further.

On 06/24/2005 at 1:24:41 PM MDT Pete Freitag wrote:
3
BTW if you find an entry to be useful (or not useful) please use my rating system at the bottom of the post.

Then I can construct which posts are most useful, and which are not.

See http://www.petefreitag.com/about/ for a list of most useful posts so far. (ooh that should auto-link)

On 10/18/2005 at 3:26:39 PM MDT devon wrote:
4
how do you leave comments on all your friends on your friends list on myspace,any help? email me about it

On 11/05/2005 at 1:06:57 AM MST Anthony wrote:
5
hey, i heard there was an auto comment bot, if anyone knows of this bot please let me know anthony.petini@comcast.net

On 11/15/2005 at 5:52:17 PM MST be dubs wrote:
6
yeah the comment bot what up with it. I know someone has one.

On 11/18/2005 at 12:15:18 PM MST zane wrote:
7
i would love an email also with that auto post bot info as well.

On 01/08/2006 at 4:29:48 PM MST Jim wrote:
8
Just a test... I like http://www.apple.com, and http://www.news.com, and http://www.google.com.

On 02/27/2007 at 6:54:00 PM MST Derrick wrote:
9
Not quite sure I understand this. http://www.cnn.com

On 12/05/2007 at 9:55:30 PM MST kl4e wrote:
10
ok i am trying this out

www.kl4e.com/music

On 03/19/2008 at 8:45:23 AM MST Jewlz wrote:
11
Hey you guys... Jewlz here... Can you comment my new pics.. please... it will be a huge favor...

thanks

much love, Jewlz




  



Spell Checker by Foundeo





Subscribe to my RSS Feed: solosub RSS
Tags