Auto-Linking Comments

June 24, 2005

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:

	"<a href=""\1"">\1</a>", 

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


Related Entries

11 people found this page useful, what do you think?


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?
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.
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 for a list of most useful posts so far. (ooh that should auto-link)
how do you leave comments on all your friends on your friends list on myspace,any help? email me about it
hey, i heard there was an auto comment bot, if anyone knows of this bot please let me know
yeah the comment bot what up with it. I know someone has one.
i would love an email also with that auto post bot info as well.
Just a test... I like, and, and
Not quite sure I understand this.
ok i am trying this out
Hey you guys... Jewlz here... Can you comment my new pics.. please... it will be a huge favor... thanks much love, Jewlz
Humm, I wonder if this works. &#87&#87&
I prefer the following for auto-linking

cfset linkRegEx = "((http|https):\/\/[[:word:]\-_]+(\.[[:word:]\-_]+)+([[:word:]\-\.,@?^=%&amp;:/~\+##]*[[:word:]\-\@?^=%&amp;/~\+##])?)"

cfset thisComment = ReReplaceNoCase(thisComment,linkRegEx,'a href="\1"[Link]&/a','All')

this regEx matched pretty mugh any URL and even ignores bad trailing punctuation.
I think is better thinking.
This is a wonderful opinion. The things mentioned are unanimous and needs to be appreciated by everyone.

I think it it the better way.

Recent Entries


did you hack my cf?