Forum Moderators: open

Message Too Old, No Replies

Amending Function That Displays Text URLs As Hyperlinks

Want to display anchor text instead of raw URL

         

skipfactor

9:10 pm on Jan 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On an asp product detail page, I use a function to link URLs from the plain text of the product descriptions in the database:
<%
Function LinkURLs(byVal strIn)
dim re, sOut
set re = New RegExp
re.global = true
re.ignorecase = true
're.multiline = true
re.pattern = _
"((mailto\:¦(news¦(ht¦f)tp(s?))\://){1}\S+)"
sOut = re.replace( strIn, _
"<A HREF=""$1"" TARGET=""_top"">$1</A>")

set re = Nothing
LinkURLs = sOut
End Function
%>

I'm looking for an amendment, new function, or better way to display anchor text instead of the raw URL. Like forums' use of "{url=www.example.com}Anchor{/url}".

skipfactor

9:37 pm on Jan 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Figured it out, sorry. Changed function to:
<%
Function LinkURLs(byVal strIn)
dim re, sOut
set re = New RegExp
re.global = true
re.ignorecase = true
're.multiline = true
re.pattern = _
"((mailto\:¦(news¦(ht¦f)tp(s?))\://){1}\S+)"
sOut = re.replace( strIn, _
"<A HREF=""$1"">$1</A>")

set re = Nothing
LinkURLs = sOut
End Function
%>

Then for the product desc. text:
<a href="page.htm">Anchor Text</a>