Auto-Linking Comments
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
- Regex to Replace Multiple Blank Lines with One - May 19, 2005
- Gravatar's not showing up? - December 18, 2006
- Widon't and Widows - September 5, 2006
- How To Make a Tag Cloud - June 24, 2005
- Last 100 Comments - May 23, 2005
Trackbacks
Trackback Address: 395/BB0952BD2BAD1FD2492011E7D41C5A13
Comments
On 06/24/2005 at 12:17:05 PM EDT 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 EDT 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 EDT 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 EDT 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 EST 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 EST 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 EST 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 EST 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 EST Derrick wrote:
9
Not quite sure I understand this. http://www.cnn.com
On 12/05/2007 at 9:55:30 PM EST kl4e wrote:
10
ok i am trying this out
www.kl4e.com/music
On 03/19/2008 at 8:45:23 AM EDT 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
On 10/25/2008 at 1:04:09 PM EDT Test wrote:
12
Humm, I wonder if this works. WWW.example.com
On 11/05/2009 at 2:16:26 PM EST Justin wrote:
13
I prefer the following for auto-linking
cfset linkRegEx = "((http|https):\/\/[[:word:]\-_]+(\.[[:word:]\-_]+)+([[:word:]\-\.,@?^=%&:/~\+##]*[[:word:]\-\@?^=%&/~\+##])?)"
cfset thisComment = ReReplaceNoCase(thisComment,linkRegEx,'a href="\1"[Link]&/a','All')
this regEx matched pretty mugh any URL and even ignores bad trailing punctuation.
Post a Comment
Recent Entries
- Cache Template in Request Setting Explained
- What Version of Java is ColdFusion Using?
- ColdFusion 9 Performance Brief from Adobe
- Request Filtering in IIS 7 Howto
- J2EE Session Cookies on ColdFusion / JRun
- Hands on ColdFusion Security Training
- ColdFusion 9 Solr Vulnerability - Are you at Risk?
- FCKEditor Year 2010 Bug for Firefox 3.6 with ColdFusion
[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
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.
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)
www.kl4e.com/music
thanks
much love, Jewlz
cfset linkRegEx = "((http|https):\/\/[[:word:]\-_]+(\.[[:word:]\-_]+)+([[:word:]\-\.,@?^=%&:/~\+##]*[[:word:]\-\@?^=%&/~\+##])?)"
cfset thisComment = ReReplaceNoCase(thisComment,linkRegEx,'a href="\1"[Link]&/a','All')
this regEx matched pretty mugh any URL and even ignores bad trailing punctuation.



add to del.icio.us



