Does you text already have some html tags
like
<HTML>
<BODY>
your text here
</BODY>
</HTML>
??
Could you post a sample text for us to work on ?
Hilaire
Main Topics
Browse All TopicsI am looking for the following stored procedure:
CREATE PROCEDURE spActivateLinks
@text varchar(8000)
AS
-- all code would go here
GO
-------------------
I simply want it to activate any potential HTML links that are contained in the text passed to it.
The following text would be parsed and converted to a link:
* External sites - "http://", "news://", "ftp://" etc etc
* Local Links - "/news" or "/news/" etc etc
-----------------
Alternatively, this can be achieved in C# but I would prefer it in SQL.
*
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
here's a link to single lined function that should do the job
http://www.eggheadcafe.com
I guess you'll manage to update the code so that it handles FTP urls too ...
Hilaire
You can use SQL server string functions to do what you want. It is tedious and verbose compared to regular expressions, but it can be done.
Here is a sample that will create a link:
DECLARE @text varchar(4000)
SET @text = 'Turn http://www.yahoo.com into a hyperlink'
DECLARE @StartIndex smallint
DECLARE @EndIndex smallint
DECLARE @URL varchar(4000)
SET @StartIndex = charindex('http:', @text)
SET @EndIndex = charindex(' ', @text, @StartIndex)
SET @URL = substring(@text, @StartIndex, @EndIndex - @StartIndex)
SELECT STUFF(@text, @StartIndex, @EndIndex - @StartIndex, '<a href="' + @URL + '">' + @URL + '</a>')
The sample is very limited. It only handles one reference in the string. You would have to add indexes to handle multiple instances of http in the string. Also, it assumes that the reference ends with space, which may not be the case.
Business Accounts
Answer for Membership
by: smaccaPosted on 2004-04-19 at 05:56:27ID: 10859017
I noticed that Expert Exchange already do exactly what I want to:
* Notice how the "http://" and "ftp://" have been made into links.
That is EXACTLY what I want to achieve.
Cheers.