Connecting Tech Pros Worldwide Help | Site Map

Get Domain Name from URL?

Jack
Guest
 
Posts: n/a
#1: Nov 21 '05
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


Shane Thomas
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Get Domain Name from URL?


"Jack" <jouin@webfoxmail.com> wrote in message
news:jouin@webfoxmail.com:
[color=blue]
> 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[/color]

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]


Jack
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Get Domain Name from URL?


Hello,

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

Thanks,

Jack

"Shane Thomas" <nothanks@goaway.com> wrote in message
news:1178chuspj0ree8@corp.supernews.com...[color=blue]
> "Jack" <jouin@webfoxmail.com> wrote in message news:jouin@webfoxmail.com:
>[color=green]
>> 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[/color]
>
> 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]
>
>[/color]


Cor Ligthert
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Get Domain Name from URL?


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" <jouin@webfoxmail.com> schreef in bericht
news:eV8UqueTFHA.2996@TK2MSFTNGP15.phx.gbl...[color=blue]
> 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
>[/color]


Closed Thread