Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Convert multiple addresses [An Answer]
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Convert multiple addresses [An Answer]

 Post Reply Post Reply
Author
C.P.A. View Drop Down
Newbie
Newbie


Joined: 26 April 2005
Location: Netherlands
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote C.P.A. Quote  Post ReplyReply Direct Link To This Post Topic: Convert multiple addresses [An Answer]
    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




Edited by C.P.A. - 28 April 2005 at 2:21pm
Back to Top
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post Posted: 01 May 2005 at 5:09pm
what if the domain ends with www?
 
something like http://www.aaawww.com
 
or like these
 
Embarrassed
Back to Top
C.P.A. View Drop Down
Newbie
Newbie


Joined: 26 April 2005
Location: Netherlands
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote C.P.A. Quote  Post ReplyReply Direct Link To This Post Posted: 01 May 2005 at 6:32pm
i dunno let me see: mmm >> com" target="_blank" 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!)


Edited by C.P.A. - 01 May 2005 at 6:35pm
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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:

Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post 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. from the string, why not just do it in one line? like:
     strVisit = Replace(strVisit,http://www.,"")
Back to Top
C.P.A. View Drop Down
Newbie
Newbie


Joined: 26 April 2005
Location: Netherlands
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote C.P.A. Quote  Post ReplyReply Direct Link To This Post 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 :)


Edited by C.P.A. - 02 May 2005 at 6:22pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.