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:
Like this? Follow me ↯Tweet Follow @pfreitag
Auto-Linking Comments was first published on June 24, 2005.
If you like reading about regex, comments, blog, rereplace, or cfml then you might also like:
- Regex to Replace Multiple Blank Lines with One
- CFParam for Integer or Empty String
- Gravatar's not showing up?
- Widon't and Widows
- How To Make a Tag Cloud
- Last 100 Comments
- Trackbacks working on my blog
- REFind and ReReplace support \r \n and \t
The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.