Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,458
    Thanks
    15
    Thanked 0 Times in 0 Posts

    parse out domain

    how can i easily parse out a domain from a string

    meaining if i take in a string http://www.xxx.com/mytestpage.html
    it will always return just the www.xxx.com without the rest of it

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    response.write Request.ServerVariables("SERVER_NAME")

    Here are the rest of the Request objects for you to look through:

    http://msdn2.microsoft.com/en-us/library/ms524602.aspx
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,458
    Thanks
    15
    Thanked 0 Times in 0 Posts
    I don't want the server variables -- I want to parse it out of a string (i'm actually taking it from referrer)

  • #4
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Well if you split the full URL on "//", and then split the remainder on "/", you're going to end up with the domain as the first element in your new array.

  • #5
    Regular Coder
    Join Date
    Jan 2005
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts
    have a look here

  • #6
    New Coder
    Join Date
    Jul 2004
    Location
    Utah, USA
    Posts
    70
    Thanks
    1
    Thanked 0 Times in 0 Posts
    what if I wanted to take "http://localhost/portfolio/attics/default.asp" and strip out "http://localhost/portfolio/". Is that possible?

  • #7
    Regular Coder
    Join Date
    Sep 2007
    Posts
    120
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Sure,

    RegExp will help you.

    HTH, Tom


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •