Hi!

I guess this is easy, but I ask anyway :)

How can I cut 'www.' and '.no' or '.com' from a string?

example input:

www.norway.no
www.somewhere.com

I want this output:

norway
somewhere

How can I do this?

Best regards,
Christopher

Re: cut something from a string by McKirahan

McKirahan
Fri Feb 03 18:51:28 CST 2006

"Christopher Brandsdal" <christopher@valdres.no> wrote in message
news:eKx4pfRKGHA.1028@TK2MSFTNGP11.phx.gbl...
> Hi!
>
> I guess this is easy, but I ask anyway :)
>
> How can I cut 'www.' and '.no' or '.com' from a string?
>
> example input:
>
> www.norway.no
> www.somewhere.com
>
> I want this output:
>
> norway
> somewhere
>
> How can I do this?

<%
Dim arrURL
Dim strURL
strURL = "www.norway.no"
arrURL = Split(strURL,".")
Response.Write arrURL(1)
%>



Re: cut something from a string by Evertjan

Evertjan
Sat Feb 04 03:59:19 CST 2006

McKirahan wrote on 04 feb 2006 in microsoft.public.inetserver.asp.general:

> "Christopher Brandsdal" <christopher@valdres.no> wrote in message
> news:eKx4pfRKGHA.1028@TK2MSFTNGP11.phx.gbl...
>> Hi!
>>
>> I guess this is easy, but I ask anyway :)
>>
>> How can I cut 'www.' and '.no' or '.com' from a string?
>>
>> example input:
>>
>> www.norway.no
>> www.somewhere.com
>>
>> I want this output:
>>
>> norway
>> somewhere
>>
>> How can I do this?
>
> <%
> Dim arrURL
> Dim strURL
> strURL = "www.norway.no"
> arrURL = Split(strURL,".")
> Response.Write arrURL(1)
> %>

<%
strURL = "www.north.of.norway.no"
arrURL = Split(strURL,".")
r = arrURL(1)
for i=2 to ubound(arrURL)-1
r = r & "." & arrURL(i)
next
Response.Write r
%>

or better imho:

<%
strURL = "www.north.of.norway.no"
Set regEx = New RegExp
regEx.Pattern = "^[^\.]+\.(.*)\.[^\.]+$"
Response.Write regEx.Replace(strURL, "$1")
%>





--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: cut something from a string by Roland

Roland
Sun Feb 05 05:57:52 CST 2006

"McKirahan" wrote in message
news:p5GdnZC-vogNZ37enZ2dnUVZ_s6dnZ2d@comcast.com...
: "Christopher Brandsdal" <christopher@valdres.no> wrote in message
: news:eKx4pfRKGHA.1028@TK2MSFTNGP11.phx.gbl...
: > Hi!
: >
: > I guess this is easy, but I ask anyway :)
: >
: > How can I cut 'www.' and '.no' or '.com' from a string?
: >
: > example input:
: >
: > www.norway.no
: > www.somewhere.com
: >
: > I want this output:
: >
: > norway
: > somewhere
: >
: > How can I do this?
:
: <%
: Dim arrURL
: Dim strURL
: strURL = "www.norway.no"
: arrURL = Split(strURL,".")
: Response.Write arrURL(1)
: %>

function justTheBeef(url)
justTheBeef = split(url,".")(1)
end function

Response.Write justTheBeef("www.norway.no")

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp