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:]]+)
Tweet
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
Comments
[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.
************* Christina
Post a Comment
Recent Entries
- Firefox Aurora now Supports Content Security Policy 1.0
- Writing Secure CFML cfObjective 2013 Slides
- Upgrading to Java 7 on Linux
- J2EE Sessions in CF10 Uses Secure Cookies
- Learn about ColdFusion Security at cfObjective 2013
- Session Loss and Session Fixation in ColdFusion
- FuseGuard 2.3 Released
- CKEditor Spell Checker Plugin


add to del.icio.us



