Link to home
Start Free TrialLog in
Avatar of dumaloo
dumaloo

asked on

Parse URL with VBScript

I have a URL such as http://www.mydomain.com/Bob.Jones on my Windows server.
I would like to parse out the "Bob" and "Jones" separately so I can use them on a web page.
How can I accomplish this?
Avatar of rg20
rg20
Flag of United States of America image

url = http://www.mydomain.com/Bob.Jones

array = split(url,".com/")

This will give you a 2 dimention array
http://www.mydomain
and
Bob.Jones

WordArray = Split(array(2), ".")
will give you
wordarray(0) = Bob
wordarray(1) = Jones
Avatar of dumaloo
dumaloo

ASKER

Thanks rg20. So how do I actually write out the values to the web page with vbscript?
Avatar of dumaloo

ASKER

So in the browser address bar, I have the following: http://www.mydomain.com/Bob.Jones

My vbscript code is as follows:

myURL = Request.ServerVariables("Query_String")
myURL = UCase(Mid(myURL, InStrRev(myURL, "/") + 1, Len(myURL)))
myDomain="http://www.mydomain.com/"
myNewURL=myDomain+myURL
response.write myNewURL ---->> returns http://www.mydomain.com/Bob.Jones

The array should return "Bob" and "Jones" separately. How can I write these two different values to the page?
The code errors out when I include the array stuff above.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of rg20
rg20
Flag of United States of America 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
Avatar of dumaloo

ASKER

Works now! Thanks
You should accept an answer and not just close the question, I done this on accident a few times
Avatar of dumaloo

ASKER

This helped me arrive at the final solution.
Just curious what were you trying to write out, if they were attached to the URL, and you were spllitting them from the URL, how did it help you get to only a partial answer?