Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting a url with code

Status
Not open for further replies.

kupe

Technical User
Sep 23, 2002
376
I have a huge list of urls to put in a database. I need to divide the urls into two collections, the basic url and the full url, as in taking

from

There's code for taking the first and last words etc from a string. But these long urls have no word breaks. The only common feature is a forward slash. Is there a way to code “gimme all before the first forward slash please?”

Cheers from a sunny English spring morning.
Kupe
 
I would suggest that look at the Split function.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
This may be long winded but why not use the Len function to find the length of the string and then cycle through the string until you find the third "/". Using a For Next loop will give it's position and then use the Mid function to seperate the string.

There's probably an easier way but using the above will definately work.
 
The Split function would be rather easier!


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Thanks, CajunCenturion and johnwm, I've had a long study of the split function, but I don't see how it can be manipulated to chop off a url at the first /. Any examples come to mind, please?
 
Dim httpAddress As Variant

httpAddress = "
httpAddress = Split(httpAddress, "/")
HttpAdress = httpAddress(0) + "//" + httpAddress(1) + httpAddress(2)

MsgBox HttpAdress


'Note: The problem with the code is that it doesn't validate proper http address. You'll need to do that check
 
Get rid of the semicolon at the end of the HttpAddress line.
Does anybody know why that keeps happening? Am I the only one with this problem. Anyway...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top