473,378 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

cut something from a string

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
Feb 3 '06 #1
3 1778
"Christopher Brandsdal" <ch*********@valdres.no> wrote in message
news:eK**************@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)
%>
Feb 4 '06 #2
McKirahan wrote on 04 feb 2006 in microsoft.public.inetserver.asp.general:
"Christopher Brandsdal" <ch*********@valdres.no> wrote in message
news:eK**************@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)
Feb 4 '06 #3
"McKirahan" wrote in message
news:p5******************************@comcast.com. ..
: "Christopher Brandsdal" <ch*********@valdres.no> wrote in message
: news:eK**************@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
Feb 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Martin Lucas-Smith | last post by:
I am trying to take a string and split it into a filename and a number where the number is what follows the *last* instance of a comma in that string. Split and explode won't work because if the...
16
by: Bob Rock | last post by:
Hello, when serializing an array of elements of a class Classname using XmlSerializer.Serialize() I get an XML like the following: <?xml version="1.0"> <ArrayOfClassname> ....... ..........
12
by: Brett Hofer | last post by:
I must be missing something - Im a veteran C++ programmer now working with C# overall I like the language but find many weird changes... Anyway Im writing code behind an aspx. In this one C#...
4
by: Rob Lykens | last post by:
I am wondering if anyone has done something like this? I want to find a label based on the passed in information. It would be awesome to find something like this: private void myvoid (int i) {...
5
by: SStory | last post by:
Hi all, I really needed to get the icons associated with each file that I want to show in a listview. I used the follow modified code sniplets found on the internet. I have left in...
0
by: InnoCreate | last post by:
Hi Everyone, I'm a newbie to the group. Hope to be able to contribute something :D I have an asp.net v1.1 web application that randomly throws the error below. Does anyone have any idea's...
11
by: matsi.inc | last post by:
I am looking to make something like a delegate that i can use in my projects but am having a hard time getting started. The behavior I am most interested in is how a delegate changes it's Invoke...
13
compman9902
by: compman9902 | last post by:
Hello, and thank you for hwlping me with this run-in with trouble. I am making a script for pig latin transulation, and there is something wrong with the "if" statement in line 51. Here is the code...
9
by: Ronald S. Cook | last post by:
Can I write If MyString = "Apple" Or MyString = "Orange" Or MyString = "Pear" Then to something more compact like If MyString In ("Apple", "Orange", "Pear") Then My last line obviously...
4
by: roundcrisis | last post by:
Hi there: I m trying to do something (check values) if one of the parameter in a procedure is used, for example let say I have the following procedures: index(int a, string specialParam,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.