Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - parsing domain from a long url
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

parsing domain from a long url

 Post Reply Post Reply
Author
mhanif View Drop Down
Groupie
Groupie
Avatar

Joined: 22 November 2007
Location: Pakistan
Status: Offline
Points: 52
Post Options Post Options   Thanks (0) Thanks(0)   Quote mhanif Quote  Post ReplyReply Direct Link To This Post Topic: parsing domain from a long url
    Posted: 10 September 2010 at 3:37pm
<%
%>
 
 
I want this to return
 
google.com.au
 
 
Please help me, i need this urgent.  just help me with the script which can parse long url into just a domain name.  if url has www, or not,  if domain is google.co.uk or google.com, whatever the extension is.   the result should be
 
like:  google.co.uk
 
Regards
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2010 at 6:49pm
Its very simple using a mixture of mid, Instr and Replace.
S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
mhanif View Drop Down
Groupie
Groupie
Avatar

Joined: 22 November 2007
Location: Pakistan
Status: Offline
Points: 52
Post Options Post Options   Thanks (0) Thanks(0)   Quote mhanif Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2010 at 11:20pm
Actually i don't know the usage of those which you mentioned. If you can code it here, if its really simple and does not take alot of time for you. I will be thanksful to you. its not for something commercial. I need it for my personal project, and i am just failing to do that. And even in php to asp converter, it is not converting properly. :(
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 18 September 2010 at 11:39am
Well, if all you want to do is grab the domain name you can use the above links to strip it down like so:

Use the Replace function to remove the "http://" and "www." part like so:

strInput = "http://www.google.com.au/?var=34sa&ada=adklfjadfa&adfaadfa=akdfadfa"
strTmp = replace(strInput,"http://","")
strTmp = replace(strTmp,"https://","")
strTmp = replace(strTmp,"www.","")


Then use the Instr Function to find the first "/" next
(being the end of the domain name now we've removed the "http://" part)

intPos = InStr(strTmp,"/")


Then use Mid to strip the end off like so:

strOutput = Mid(strTmp,1,intPos)


Putting it all together you get:

strInput = "http://www.google.com.au/?var=34sa&ada=adklfjadfa&adfaadfa=akdfadfa"

strTmp = replace(strInput,"http://","")
strTmp = replace(strTmp,"https://","")
strTmp = replace(strTmp,"www.","")

intPos = InStr(strTmp,"/")

strOutput = Mid(strTmp,1,intPos)

Response.Write(strOutput)


The links I provided did explain the functions (which is why I provided them), So you should of been able to do this your self.

And if you know PHP then the this page has helped me go from ASP to PHP.

S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
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.