Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

How to remove part of a string

Hi all,
I was wondering how I could remove part of a string that is on the right of a slash (/).
For example:
Before - aldsjkfj/ksjldf
After - aldsjkfj/
Thanks Jobartley515
[217 byte] By [jobartley515] at [2007-11-11 8:42:32]
# 1 Re: How to remove part of a string
dim k as long
k = instr(myString,"/")
if k > 0 then newString = left$(myString, k-1)
mstraf at 2007-11-11 17:25:05 >
# 2 Re: How to remove part of a string
Although, jobartley515 wanted to keep the "/" so :

if k > 0 then newString = left$(myString, k)

;-)
gupex at 2007-11-11 17:26:05 >
# 3 Re: How to remove part of a string
good point! Thanks my friend
mstraf at 2007-11-11 17:27:15 >
# 4 Re: How to remove part of a string
Hi,

Thanks for your responses.
They help me to a point, but I was wondering if you could help me again.

I wish to remove part of the string to the right of the last "/" slash in the string.

Before:

asdfasdf/asdfasdfasdf/asdfasdfasdf

After:

asdfasdf/asdfasdfasdf/

Again thanks for your help.

Jobartley
jobartley515 at 2007-11-11 17:28:09 >
# 5 Re: How to remove part of a string
Use the original code with InstrRev instead of Instr.

dim k as long
k = InStrRev(myString,"/")
if k > 0 then newString = left$(myString, k)

Steve.
Steve Grant at 2007-11-11 17:29:08 >