Print Page | Close Window

converting a web site address to link

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14187
Printed Date: 30 March 2026 at 11:30am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: converting a web site address to link
Posted By: moti
Subject: converting a web site address to link
Date Posted: 10 March 2005 at 9:52am
I have textarea
I want if user enter a web site address or email address after posting it with that text area it automatically converted to a link
for example  in this forum in editor if you type a link like this
http://www.webwiz.net - www.webwiz.net
 
after posting it automatically will change it to a link
ot if you type this
 
http://www.sd - www.sd

how can I do it with javascript or ASP scripts
 
Wink



Replies:
Posted By: Gullanian
Date Posted: 10 March 2005 at 1:10pm
Read up on string manipulation in ASP.  Basically just search the string for things that look like web addresses.  Verify it, than manipulate it.


Posted By: moti
Date Posted: 10 March 2005 at 4:14pm
could you write the code?
I think we should use Replace function, Geek


Posted By: Gullanian
Date Posted: 10 March 2005 at 4:44pm
That's a lot of code.  'We' probably should use the replace function at some point.  I don't have the time sorry.  Take a look on google, it's out there somewhere.


Posted By: tcampione
Date Posted: 12 March 2005 at 9:01pm
The basic idea is:
 
userAddress=request.form("address")
 
response.write ("<a href="  & useraddress & ">" &  useraddress & "</a>")
 
 
You are simply writing a standard formatted link using the formfield value.
 


-------------
http://www.audience-response-rentals.com/ - Audience Response Systems | http://www.nyrfanclub.com/ - NY Rangers Fan Club


Posted By: Gullanian
Date Posted: 12 March 2005 at 10:09pm
I think he was talking more along the lines of having a chunk of text like:

wefiwhfeiopwehf iphwfeih ihfwihewfpi hipfwepih www.drum-world.com fwihpwfe wfepiwef pijfwe wefpijwef

And then finding any hyperlinks and converting them to HTML


Posted By: Mart
Date Posted: 13 March 2005 at 3:39am
it's in VB.NET but you should be able to convert it to asp 3.0, all it does is search a string using regular expressions for a link and then puts the relevant tags around it.



If Not IsDBNull(desc) Then
            Dim temp As String = desc

            Dim mc As MatchCollection = Regex.Matches(temp, "http://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?", RegexOptions.IgnoreCase)

            For Each m As Match In mc
                If Not m.Value.Length > 40 Then
                &n bsp;   temp = temp.Replace(m.Value, "<a href=""" & m.Value & """ target=""_blank"">" & m.Value & "</a>")
                Else
                &n bsp;   temp = temp.Replace(m.Value, "<a href=""" & m.Value & """ target=""_blank"">Click here to visit link</a>")
                End If
            Next

            Return temp
        Else
            Return String.Empty
        End If




Posted By: Bluefrog
Date Posted: 14 March 2005 at 10:57pm
Mart did a good article on regular expressions in .NET at DevJunkies.com. Most of it is still applicable to ASP. I needed to do a task cleaning some text in .NET and used WWF code with a few tweaks. Very simple stuff.

Just read the article for a good overview.



-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music


Posted By: Bluefrog
Date Posted: 14 March 2005 at 11:04pm
Here's another start on RegEx stuff. http://www.regexlib.com/REDetails.aspx?regexp_id=903



-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net