Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > cut something from a string

Reply
Thread Tools

cut something from a string

 
 
Christopher Brandsdal
Guest
Posts: n/a
 
      02-03-2006
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


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      02-04-2006
"Christopher Brandsdal" <> wrote in message
news:...
> 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)
%>


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      02-04-2006
McKirahan wrote on 04 feb 2006 in microsoft.public.inetserver.asp.general:

> "Christopher Brandsdal" <> wrote in message
> news:...
>> 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)
 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      02-05-2006
"McKirahan" wrote in message
news5GdnZC-...
: "Christopher Brandsdal" <> wrote in message
: news:...
: > 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath query for <?define something="something" ?> Pekka Järvinen XML 2 04-29-2008 08:12 PM
How to find and replace something that is nested inside something else? alainfri@gmail.com Perl Misc 4 05-31-2007 11:50 PM
Cut String & Insert in String vunet.us@gmail.com ASP General 5 05-14-2007 08:20 PM
var Something= new Something() What does it mean ? pamelafluente@libero.it Javascript 9 10-05-2006 02:43 PM
umm... something... template(s)... something else... pointer(s)... and such... 0.o yah, I'm hopeless and clueless o.0 C++ 4 10-13-2004 10:34 PM



Advertisments