473,473 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get Domain Name from URL?

Hello,

I need to get:

microsoft.com

From these possible string:

www.microsoft.com
http://www.microsoft.com
http://microsoft.com
microsoft.com
sql.microsoft.com
htttp://sql.microsoft.com

Thanks for any help,

Jack
Nov 21 '05 #1
3 8356
"Jack" <jo***@webfoxmail.com> wrote in message
news:jo***@webfoxmail.com:
Hello,

I need to get:

microsoft.com

From these possible string:

www.microsoft.com
http://www.microsoft.com
http://microsoft.com
microsoft.com
sql.microsoft.com
htttp://sql.microsoft.com


Regular Expressions is one way.

Imports System.Text.RegularExpressions
....
Dim rx As Regex = New Regex("(?<1>microsoft.com)")
Dim mt As Match = rx.Match("http://www.whatever.microsoft.com")
If mt.Success Then
retval = mt.Groups(1).ToString
End If

There's decent pattern matching help in MSDN and Google.

--

-shane

Shane Thomas
HSI [http://www.hsisoft.com]
Nov 21 '05 #2
Hello,

Thanks!! I also need it to work on any domain name and just return the
domainname.TopLevelDomain

Thanks,

Jack

"Shane Thomas" <no******@goaway.com> wrote in message
news:11*************@corp.supernews.com...
"Jack" <jo***@webfoxmail.com> wrote in message news:jo***@webfoxmail.com:
Hello,

I need to get:

microsoft.com

From these possible string:

www.microsoft.com
http://www.microsoft.com
http://microsoft.com
microsoft.com
sql.microsoft.com
htttp://sql.microsoft.com


Regular Expressions is one way.

Imports System.Text.RegularExpressions
...
Dim rx As Regex = New Regex("(?<1>microsoft.com)")
Dim mt As Match = rx.Match("http://www.whatever.microsoft.com")
If mt.Success Then
retval = mt.Groups(1).ToString
End If

There's decent pattern matching help in MSDN and Google.

--

-shane

Shane Thomas
HSI [http://www.hsisoft.com]

Nov 21 '05 #3
Jack,

This gives you back the domain name.

Dim myUri As New
Uri("http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemuriclasshosttopic.asp")
messagebox.show(myUri.Host)

I don't not know a method to strip a domainname to smaller parts. There are
all kind of domainnames you know. (2 dots, 3dots, 4dots)

I hope this helps,

Cor
"Jack" <jo***@webfoxmail.com> schreef in bericht
news:eV**************@TK2MSFTNGP15.phx.gbl...
Hello,

I need to get:

microsoft.com

From these possible string:

www.microsoft.com
http://www.microsoft.com
http://microsoft.com
microsoft.com
sql.microsoft.com
htttp://sql.microsoft.com

Thanks for any help,

Jack

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jordan | last post by:
Suppose I register a domain name, MyDomain.com, through register.com (or any other of the many domain name registrars). I own the domain name. The domain name goes into the global DNS database. ...
3
by: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
3
by: Joe User | last post by:
Hi - I found the class below on another website (www.devx.com) and can't seem to figure out how to make a call to this class to retrieve the machines and put them in a listbox. I am definitely a...
5
by: Dany C. | last post by:
We have install a valid SSL certificate issued to www.mycompany.com on our web server running IIS 6.0 / win2003 SP1. Then we have created a sub domain pointing to the same server for our web...
6
by: Adam Tibi | last post by:
Hello, I want to get the right most name of the a domain name, for example: if the domain is www.myweb.com , I want to get myweb.com something.myweb.com --> myweb.com www.myweb.com.au --> ...
2
by: johkar | last post by:
I am getting an Access denied error when I write to a new window. The situation and code are outlined below. I am setting the domain in the main window. The problem is that the window I am...
10
by: Sridhar | last post by:
HI, I am having problems setting up a website so that it will be available only inside the domain. We have three servers. One is iis server and second one is internal server and the third one is...
9
by: Sam | last post by:
Validate domain name context Hello , Today I want to make sure from a given text is a domain style or not. for example : the domain can be example.com or example.com.us or example.us so ,...
6
by: Guy Macon | last post by:
While I agree with the sentiment, the oringinal title on this thread ("OT: Specially for , why you should always use example.com for obfuscating domains") is wrong. There are other reserved domain...
3
by: yaghout | last post by:
Hi, i need to check and retrive the mx records for a domain using asp .net , i am using .net 1.1 and prefer to use this framework version . ok , i found that i should use DNS protocol to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.