Print Page | Close Window

Convert multiple addresses [An Answer]

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=14853
Printed Date: 30 March 2026 at 6:55am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Convert multiple addresses [An Answer]
Posted By: C.P.A.
Subject: Convert multiple addresses [An Answer]
Date Posted: 27 April 2005 at 7:41am
Hello Dudes,

Instead of my first trial to get somehelp, I have now the created the solution. However, Don Pyers helped me out with a great start!

So if you are ever in a piggle and need to replace http://www.blabla.com addresses because your boss wants it ... here comes the solution.



Dim strText, strReturned, strSearchString, strEndStringChars, strStartPos, strEndPos, strLength
Function subPullStrings(strText)
If  instr(strText,"http:") = 0 Then
 If len(strTextToReplace) = 0 then
    subPullStrings = strText
    Exit Function
 End If
End If

strText = Replace(strText,"http://www.","*66775588*")
strText = Replace(strText,"www.","*66775588*")
strText = Replace(strText,"*66775588*","http://www.")

Do while instr(strText,"http:") > 0
 strSearchString = "http:"
 strEndStringChars = " "
    strLength = 0
    strStartPos = instr(1, strText, strSearchString)
    strEndPos = instr(strStartPos + 1, strText, strEndStringChars)
    strLength = strEndPos - strStartPos
    strReturned = mid(strText,strStartPos + len(strSearchString),strLength - len(strSearchString) )
    strStartPos = strEndPos + 1
     strVisit = strReturned
     strVisit = Replace(strVisit,"http:","")
     strVisit = Replace(strVisit,"//","")
     strVisit = Replace(strVisit,"www.","")
     tempVisit = Split(strVisit,".")
     strVisit = tempVisit(0)
    strFinal = " <a href=""*444555*" + strReturned + """ target=""_blank"" title=""Visit: " + strVisit + """>" & strVisit & "</a> "
   strFinal = Replace(strFinal,"'","")
   strFinal = Replace(strFinal,",","")
   strFinal = Replace(strFinal,"&","&amp;")
  strText = Replace(strText,"http:" & strReturned,strFinal)
Loop
  strText = Replace(strText,"*444555*","http:")
 subPullStrings = strText
End Function


Addresses can start with or HTTP: or WWW.

strMeString = "this is great stuff and can be found at http://www.webwiz.net and that is just great!"
strMeString = strMeString + " "

Next is to apply the function like this:
subPullStrings(strMeString)

et voila!

Happy coding ye all Clap




-------------
C.P.A. » The more you find out about the world, the more opportunities warmly welcome you.



Replies:
Posted By: zMaestro
Date Posted: 01 May 2005 at 5:09pm
what if the domain ends with www?
 
something like http://www.aaawww.com - http://www.aaawww.com
 
or like http://www.whois.sc/domain-explorer/?q=www%24&bn=y&filter=y&bh=B&right=y&pool=A&rows=100&bc=25&last=r&tab=3 - these
 
Embarrassed


Posted By: C.P.A.
Date Posted: 01 May 2005 at 6:32pm
i dunno let me see: mmm >> http://www.aaa%20%3ca%20href=/" http://www.com="" title="Bezoek: com - com" title="Visit: aaacom">aaacom

damn, that sucks! Any sugestions ... ?


(btw it's for a dutch system ... changes that the domains end with www are small but about the second link, you got a point!)


-------------
C.P.A. » The more you find out about the world, the more opportunities warmly welcome you.


Posted By: dj air
Date Posted: 01 May 2005 at 7:08pm
what about using the left function to only take the www from it like

Left(strVisit,11)

that is http://www.

or change the sequance from http: then www. then // to //www. then http:



Posted By: ub3rl337ch3ch
Date Posted: 01 May 2005 at 7:49pm
if all you're doing with
     strVisit = Replace(strVisit,"http:","")
     strVisit = Replace(strVisit,"//","")
     strVisit = Replace(strVisit,"www.","")
is cutting the http://www - http://www . from the string, why not just do it in one line? like:
     strVisit = Replace(strVisit, http://www. - http://www. ,"")


Posted By: C.P.A.
Date Posted: 02 May 2005 at 8:45am
The problem is that one can have addresses starting with:

http://www.address.com
http://address.com
www.address.com

Changing the sequence will not effect it correctly to pass these forms of adresses, cutting the string the way I do is a solution for this.

well; it is by far not as simple as I hoped for, I haven't found an answer yet but I'll be working on it :)


-------------
C.P.A. » The more you find out about the world, the more opportunities warmly welcome you.



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