473,385 Members | 1,645 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,385 software developers and data experts.

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.servervaraibles method:

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

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

"Riverbend"

Many thanks

Jason

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

"jason" <ja***@catamaranco.com> wrote in message
news:OY**************@TK2MSFTNGP10.phx.gbl...
How would I strip out everything from before the last "/" in the following
string generated from request.servervaraibles 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.servervaraibles 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.essermanyachtsales.com/riverbend/"
ar = split(str,"/")
response.write ar(ubound(ar))

However, who is to say that your string might not contain
"http://www.essermanyachtsales.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.essermanyachtsales.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.essermanyachtsales.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***@TRASHaspfaq.com> wrote in message
news:ec**************@tk2msftngp13.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*******@yahoo.com> wrote in message
news:O7**************@TK2MSFTNGP10.phx.gbl...
Aaron Bertrand - MVP wrote:
However, who is to say that your string might not contain
"http://www.essermanyachtsales.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.essermanyachtsales.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***@TRASHaspfaq.com> wrote in message
news:ec**************@tk2msftngp13.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
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"...
6
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. ...
6
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...
32
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...
3
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...
4
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...
4
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...
15
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
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....
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.