Link to home
Start Free TrialLog in
Avatar of smacca
smaccaFlag for Australia

asked on

Parse text and create HTML links where appropriate

I 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.
  *
Avatar of smacca
smacca
Flag of Australia image

ASKER

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.
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
SOLUTION
Avatar of Hilaire
Hilaire
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree with hilaire here. I'm sure it would be possible to do some sort of string replacement. however the problem is that it would be much more effecient and easier to use a language that supports reg expressions
Avatar of arbert
arbert

I agree with the above.  It's not totally clear what you're working with, but usually it's the client application that decides if a link is encoded as an HREF--not the database app....
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I was wondering, does anyone know how to do this in ASP?