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:
- 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
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.
- Facebook API Now Requires Review for user_friends Permission
- Docker Container exited with code 137
- Why is my cron.daily script not running?
- Announcing FuseGuard Version 3
- CFSummit 2017
- Java Unlimited Strength Crypto Policy for Java 9 or 1.8.0_151
- Java 9 Security Enhancements
- Upcoming CFML Conferences in April 2017