cut something from a string

  • Thread starter Christopher Brandsdal
  • Start date
E

Evertjan.

McKirahan wrote on 04 feb 2006 in microsoft.public.inetserver.asp.general:
<%
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")
%>
 
R

Roland Hall

in message
: : > 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top