13 5145
Hi
Hi Don't think that solves the problem....
what if the string is http://subdomain.test123.com/testpage.html
Try this :
Function SeparateDomain(strDomain As String) As String
Dim i As Long, j As Long, k As Long
k = InStr(1, strDomain, "//") + 2
i = InStr(1, strDomain, ".")
j = InStr(k, strDomain, "/")
SeparateDomain = Mid(strDomain, i + 1, (j - i) - 1)
End Function
Regards
Jens
Hi Don't think that solves the problem....
>
what if the string is http://subdomain.test123.com/testpage.html
Sorry, you are right.
My code extracts only first level domain.
The solution proposed by Jens Schilling seems ok.
--
PBsoft di Gabriele Bertolucci www.pbsoft.it
skype: pbsoftsolution
Thanks .. that works cool
Ganesh J. Acharya
Jens Schilling wrote:
Hi
Hi Don't think that solves the problem....
what if the string is http://subdomain.test123.com/testpage.html
Try this :
Function SeparateDomain(strDomain As String) As String
Dim i As Long, j As Long, k As Long
k = InStr(1, strDomain, "//") + 2
i = InStr(1, strDomain, ".")
j = InStr(k, strDomain, "/")
SeparateDomain = Mid(strDomain, i + 1, (j - i) - 1)
End Function
Regards
Jens
no buddy it's not working..
if i remove "www" it just does not work
thanks!
ganesh
Jens Schilling wrote:
Hi
Hi Don't think that solves the problem....
what if the string is http://subdomain.test123.com/testpage.html
Try this :
Function SeparateDomain(strDomain As String) As String
Dim i As Long, j As Long, k As Long
k = InStr(1, strDomain, "//") + 2
i = InStr(1, strDomain, ".")
j = InStr(k, strDomain, "/")
SeparateDomain = Mid(strDomain, i + 1, (j - i) - 1)
End Function
Regards
Jens
Hi
no buddy it's not working..
if i remove "www" it just does not work
I think it works with all your samples - but changing the rules changes the
results ;-)
All your samples either show a leading "www" or a leading subdomain, so that
it's easy to locate the first dot in the string and cut it respectively.
But if you will let me know how to recognize that a URL like
"http://dsih.test4.co.uk/test.html" contains a subdomain and not only misses
the leading "www" I will try it again.
Regards
Jens
OK.........
this one worked for me
Dim StrDomain
Dim i As Long, j As Long, k As Long
Dim s() As String
StrDomain = rCell
k = InStr(1, StrDomain, "//") + 2
If InStr(1, StrDomain, "www") 0 Then
i = InStr(1, StrDomain, ".")
Else
i = InStr(1, StrDomain, "//") + 1
End If
j = InStr(k, StrDomain, "/")
StrDomain = Mid(StrDomain, i + 1, (j - i) - 1)
ExtractDomain = StrDomain
Hi,
this one worked for me
Following your first post, it won't......
>How can I extract the only the domain name from the following list? to give the following output?
URL
=========
....... http://dsih.test4.co.uk/test.html
Domain
=========
......
test4.co.uk
Your code in direct window :
?ExtractDomain("http://dsih.test4.co.uk/test.html")
dsih.test4.co.uk
And what about the sample in your second post ?
<http://subdomain.test123.com/testpage.html>
?ExtractDomain("http://subdomain.test123.com/testpage.html")
subdomain.test123.com
Thought you want to cut the subdomain - but when it works for you .....
Regards
Jens
Yes it is surely cutting the subdomain too....
I've tested that with 300 URL's in my list... it does not make a single
mistake
Jens Schilling wrote:
Hi,
this one worked for me
Following your first post, it won't......
How can I extract the only the domain name from the following list? to
give the following output?
URL
=========
...... http://dsih.test4.co.uk/test.html
Domain
=========
.....
test4.co.uk
Your code in direct window :
?ExtractDomain("http://dsih.test4.co.uk/test.html")
dsih.test4.co.uk
And what about the sample in your second post ?
<http://subdomain.test123.com/testpage.html>
?ExtractDomain("http://subdomain.test123.com/testpage.html")
subdomain.test123.com
Thought you want to cut the subdomain - but when it works for you .....
Regards
Jens
Hi,
Yes it is surely cutting the subdomain too....
I've tested that with 300 URL's in my list... it does not make a
single mistake
>?ExtractDomain("http://subdomain.test123.com/testpage.html") subdomain.test123.com
My test with your code results as aforesaid....
Never mind ! It works for you, and that's OK !
Regards
Jens
Ya this code i paste gives me a sub domain only..
you are right Jens Schilling...
but somehow for the problem i was facing ... i actually need the
subdomain...
good i got that.. but there's another problem in that code...
for http://google.com/ i get google.com
but for http://google.com i don't get anything
ganesh gs******@gmail.com wrote:
Yes it is surely cutting the subdomain too....
I've tested that with 300 URL's in my list... it does not make a single
mistake
Jens Schilling wrote:
Hi,
this one worked for me
Following your first post, it won't......
>How can I extract the only the domain name from the following list? to
>give the following output?
URL
=========
...... http://dsih.test4.co.uk/test.html
Domain
=========
.....
test4.co.uk
Your code in direct window :
?ExtractDomain("http://dsih.test4.co.uk/test.html")
dsih.test4.co.uk
And what about the sample in your second post ?
<http://subdomain.test123.com/testpage.html>
?ExtractDomain("http://subdomain.test123.com/testpage.html")
subdomain.test123.com
Thought you want to cut the subdomain - but when it works for you .....
Regards
Jens
Hi,
you are right Jens Schilling...
;-)
good i got that.. but there's another problem in that code...
for http://google.com/ i get google.com
but for http://google.com i don't get anything
Would expect that you should get at least an error message (error 5 --j =
0) ;-)
So, quick and (very) dirty try :
........
j = InStr(k, strDomain, "/")
If Not j 0 Then
j = InStr(k, strDomain & "/", "/")
End If
Regards
Jens This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sambalaz |
last post by:
What is the best way to achieve authentication between two seperate non
trusting domains.
Scenario:
- i have a winform client application that resides on domain A
- the application makes calls...
|
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.
...
|
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...
|
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...
|
by: Jason Hawthorne |
last post by:
I am trying to get this code to work in a class file that I use in all
of my pages.
Public Shared Function Check_Site() As String
Dim arr() As String
Dim coll As NameValueCollection
coll...
|
by: dandorey1 |
last post by:
I'm currently in the process of writing a realtime telephony
application. I've designed it with a fairly simply plugin architecture.
When I first started reading about this the general suggestion...
|
by: MarkusJNZ |
last post by:
Hi, I have a website called www.websitename.com which is an ASP.NET
2.0 website.
I need to create another application (Which I want to be totally
seperate from the above website) but for...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |