Skip to main content
Participant
August 4, 2008
Question

Dynamically Adding '<a href>URL</a>' to Content's URL

  • August 4, 2008
  • 3 replies
  • 380 views
Content people insert FQAs into a database table with plain text (no html code) from time to time.

I will need dynamically find a url string within a content/paragraph, e.g.:
“… posted on the Internet at www.hre.com?id=68. The changes to the list …”
then replace the link to:
“… posted on the Internet at <a href=” http://www.hre.com?id=68”>www.hre.com?id=68</a>. The changes to the list …”

Right now what I did is manually put the “www.hre.com?id=68” into a database table, then replace it to “<a href=”www.hre.info?id=68”>www.hre.com</a>”.

I am not sure regular expression will help.

Is any CF function, such as len(), etc. to detect “www…”, or “ http://...” in a paragraph, then count the string’s length (www.hre.com?id=68), then replace with <a href /> tag?

Thanks in advance!
Kevin
This topic has been closed for replies.

3 replies

kheAuthor
Participant
August 5, 2008
Thanks both Lan and Daverms, the ActivateURL cfscript works very well!

Kevin
Inspiring
August 5, 2008
Hi Kevin,

ActivateURL udf can get that done for you, You can download that at,

http://cflib.org/udf/ActivateURL

HTH
Inspiring
August 4, 2008
khe wrote:
>
> I am not sure regular expression will help.
>

Regular expressions is probably what you will want to use with the CF
ReReplace() and|or ReFind() functions.

But I'll leave it to others better then I with regex syntax to help with
the precise code.