473,890 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String manipulation of a URL - strip preceding characters?

How would I strip out everything from before the last "/" in the following
string generated from request.serverv araibles method:

http://www.essermanyachtsales.com/riverbend/

....so that I was just left with:

"Riverbend"

Many thanks

Jason

Jul 19 '05 #1
7 6223
url = "http://www.essermanyac htsales.com/riverbend/"
url = split(url, "/"): response.write url(3)

"jason" <ja***@catamara nco.com> wrote in message
news:OY******** ******@TK2MSFTN GP10.phx.gbl...
How would I strip out everything from before the last "/" in the following
string generated from request.serverv araibles method:

http://www.essermanyachtsales.com/riverbend/

...so that I was just left with:

"Riverbend"

Many thanks

Jason

Jul 19 '05 #2
jason wrote:
How would I strip out everything from before the last "/" in the
following string generated from request.serverv araibles method:

http://www.essermanyachtsales.com/riverbend/

...so that I was just left with:

"Riverbend"

Many thanks

Jason

This particular string is easy:

dim str,ar
str="http://www.essermanyac htsales.com/riverbend/"
ar = split(str,"/")
response.write ar(ubound(ar))

However, who is to say that your string might not contain
"http://www.essermanyac htsales.com/riverbend/default.asp"?
Now, you would have to do this:
ar = split(str,"/")
response.write ar(ubound(ar)-1)

So, use If:

ar = split(str,"/")
if right(str,1) = "/" then
response.write ar(ubound(ar))
else
response.write ar(ubound(ar)-1)
end if

Of course, you have to check to make sure str contains any characters at all
....

HTH,
Bob Barrows
Jul 19 '05 #3
Aaron Bertrand - MVP wrote:
However, who is to say that your string might not contain
"http://www.essermanyac htsales.com/riverbend/default.asp"?
Now, you would have to do this:
ar = split(str,"/")
response.write ar(ubound(ar)-1)


Except what if it is
"http://www.essermanyac htsales.com/riverbend/subfolder/default.asp"?

This is where using ar(3) would always get the base subfolder...


True - depends on what he wants. He DID say " ... everything from before the
last "/" ..."

Bob
Jul 19 '05 #4
> > This is where using ar(3) would always get the base subfolder...

True - depends on what he wants. He DID say " ... everything from before the last "/" ..."


Right, which is why I didn't say, "you should use ar(3) instead." :-)
Jul 19 '05 #5
I guess I should be specific that I cannot always know in advance how many
subfolders there will be after the url...BUT...I always need to know what is
the LAST subfolder and its content...

Does this make sense....

Does ar(3) still work is it fixed folder?
"Aaron Bertrand - MVP" <aa***@TRASHasp faq.com> wrote in message
news:ec******** ******@tk2msftn gp13.phx.gbl...
This is where using ar(3) would always get the base subfolder...


True - depends on what he wants. He DID say " ... everything from before

the
last "/" ..."


Right, which is why I didn't say, "you should use ar(3) instead." :-)

Jul 19 '05 #6
Thanks
"Bob Barrows" <re*******@yaho o.com> wrote in message
news:O7******** ******@TK2MSFTN GP10.phx.gbl...
Aaron Bertrand - MVP wrote:
However, who is to say that your string might not contain
"http://www.essermanyac htsales.com/riverbend/default.asp"?
Now, you would have to do this:
ar = split(str,"/")
response.write ar(ubound(ar)-1)
Except what if it is
"http://www.essermanyac htsales.com/riverbend/subfolder/default.asp"?

This is where using ar(3) would always get the base subfolder...


True - depends on what he wants. He DID say " ... everything from before

the last "/" ..."

Bob

Jul 19 '05 #7
Thanks - stupid question: What if I always wanted to get the LAST subfolder
in the url no matter how many subfolders appear in the url....would this
still work?

- Jason
"Aaron Bertrand - MVP" <aa***@TRASHasp faq.com> wrote in message
news:ec******** ******@tk2msftn gp13.phx.gbl...
This is where using ar(3) would always get the base subfolder...


True - depends on what he wants. He DID say " ... everything from before

the
last "/" ..."


Right, which is why I didn't say, "you should use ar(3) instead." :-)

Jul 19 '05 #8

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

Similar topics

5
18215
by: Phrederik | last post by:
Hey all! New to javascript and still getting my head around strings... Consider the following line of code... var path = location.pathname; ....after execution, the variable "path" contains something like "file:///C:/Documents%20and%20Settings/user/Desktop/Test/fileread.htm"
6
3544
by: Mark | last post by:
Hi, My page has a table with many columns such that the right-side of the table gets chopped off when printed. I specify a table width of 100%, but otherwise no cell dimensions are specified. The culprits are 2 wide columns which contain e-mail addresses. I can get the page to fit entirely on the printer output if the browser would break the e-mail address string at the '@' symbol. What I've done for now is replaced the '@' in all...
6
9101
by: Mark C | last post by:
All, Is there such a function that can strip all non alpha ( not between a-z) characters from a string? I have a function that I currently use that will strip one character at a time from a string that I tried tweaking without success. Any help would be much appreciated. Thanks in advance, Mark C. hereinde@yahoo.com
32
14942
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
3
2630
by: David Pratt | last post by:
Hi. I am splitting a string on a non whitespace character. One or more whitespace characters can be returned as items in the list. I do not want the items in the list that are only whitespace (can be one or more characters of whitespace) and plan to use string.strip on those items that are not only whitespace (to remove any whitespace from front or back of items). What kind of efficient test can I use to obtain only list items returned...
4
3504
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if substrings need be replaced, or one character needs be changed, what shall I do? Is it better to convert strings to UCS-32 before manipulation? But on Windows, wchar_t is 16 bits which isn't enough for characters which can't be simply encoded...
4
3036
by: vvenk | last post by:
Hello: I have a string, "Testing_!@#$%^&*()". It may have single and double quotations as well. I would like to strip all chararcters others than a-z, A-Z, 0-9 and the comma. I came across the following snippet in the online help but the output does not change at all:
15
50303
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
3
2377
by: Colin J. Williams | last post by:
The Library Reference has strip( ) Return a copy of the string with the leading and trailing characters removed. The chars argument is a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a
0
9812
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11212
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10799
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10446
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8004
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7154
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4655
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4255
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3263
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.