Auto-Linking Comments
Published on June 24, 2005
By Pete Freitag
By Pete Freitag
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:]]+)
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
The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.
Try Fixinator