By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,633 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,633 IT Pros & Developers. It's quick & easy.

cut from string using JScript

P: n/a
I have this string:

/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg

If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how would
I do this?

In VBScript I could find the first "/" from the back of the sentence, and
cut everything before that, but I'm not shore how to do this in JScript...

The string I want to end up with is Winnie-the-Pooh 1024x768.jpg

Any idea??


Jul 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Why do you want to use JScript to do this?

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Christopher Brandsdal" <br*******@binaer.no> wrote in message
news:#p**************@TK2MSFTNGP11.phx.gbl...
I have this string:

/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg

If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how would I do this?

In VBScript I could find the first "/" from the back of the sentence, and
cut everything before that, but I'm not shore how to do this in JScript...

The string I want to end up with is Winnie-the-Pooh 1024x768.jpg

Any idea??

Jul 19 '05 #2

P: n/a
because the rest 550 lines of code in this .asp document is in JScript :)

Think it's best to use JScript in this case
"Steven Burn" <pv*@noyb.com> skrev i melding
news:e3**************@TK2MSFTNGP09.phx.gbl...
Why do you want to use JScript to do this?

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Christopher Brandsdal" <br*******@binaer.no> wrote in message
news:#p**************@TK2MSFTNGP11.phx.gbl...
I have this string:

/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg

If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how

would
I do this?

In VBScript I could find the first "/" from the back of the sentence, and cut everything before that, but I'm not shore how to do this in JScript...
The string I want to end up with is Winnie-the-Pooh 1024x768.jpg

Any idea??


Jul 19 '05 #3

P: n/a
hehe, good reason ;o)

You may want to take a look at the following;

http://www.activeserverpages.ru/iish.../htm/JStoc.htm

http://msdn.microsoft.com/library/en...fjscriptlangua
gereference.asp

http://raqxtr.sstar.com/caspdoc/html..._reference.htm

http://17.webmasters.com/caspdoc/htm..._reference.htm

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Christopher Brandsdal" <br*******@binaer.no> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
because the rest 550 lines of code in this .asp document is in JScript :)

Think it's best to use JScript in this case
"Steven Burn" <pv*@noyb.com> skrev i melding
news:e3**************@TK2MSFTNGP09.phx.gbl...
Why do you want to use JScript to do this?

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Christopher Brandsdal" <br*******@binaer.no> wrote in message
news:#p**************@TK2MSFTNGP11.phx.gbl...
I have this string:

/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg

If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how

would
I do this?

In VBScript I could find the first "/" from the back of the sentence, and cut everything before that, but I'm not shore how to do this in JScript...
The string I want to end up with is Winnie-the-Pooh 1024x768.jpg

Any idea??



Jul 19 '05 #4

P: n/a
hmm thanks :)

"Steven Burn" <pv*@noyb.com> skrev i melding
news:OT**************@TK2MSFTNGP11.phx.gbl...
hehe, good reason ;o)

You may want to take a look at the following;

http://www.activeserverpages.ru/iish.../htm/JStoc.htm

http://msdn.microsoft.com/library/en...fjscriptlangua gereference.asp

http://raqxtr.sstar.com/caspdoc/html..._reference.htm

http://17.webmasters.com/caspdoc/htm..._reference.htm

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Christopher Brandsdal" <br*******@binaer.no> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
because the rest 550 lines of code in this .asp document is in JScript :)
Think it's best to use JScript in this case
"Steven Burn" <pv*@noyb.com> skrev i melding
news:e3**************@TK2MSFTNGP09.phx.gbl...
Why do you want to use JScript to do this?

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Christopher Brandsdal" <br*******@binaer.no> wrote in message
news:#p**************@TK2MSFTNGP11.phx.gbl...
> I have this string:
>
> /sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg
>
> If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how would
> I do this?
>
> In VBScript I could find the first "/" from the back of the
sentence, and
> cut everything before that, but I'm not shore how to do this in

JScript...
>
> The string I want to end up with is Winnie-the-Pooh 1024x768.jpg
>
> Any idea??
>
>
>
>



Jul 19 '05 #5

P: n/a
Christopher Brandsdal wrote on 03 jun 2004 in
microsoft.public.inetserver.asp.general:
/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg

If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how
would I do this?

In VBScript I could find the first "/" from the back of the sentence,
and cut everything before that, but I'm not shore how to do this in
JScript...

The string I want to end up with is Winnie-the-Pooh 1024x768.jpg


t="/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg"

t=t.replace(/.*\//,"")

alert(t)

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #6

P: n/a
Pretty much the same as VBScript.

var s = "/sites/foo/bar.jpg";
Response.Write(s.substring(s.lastIndexOf("/")+1, s.length));

So let me ask, if you're more comfortable with VBScript, why are you
continuing to use JScript... or why don't you have JScript documentation
handy?

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Christopher Brandsdal" <br*******@binaer.no> wrote in message
news:#p**************@TK2MSFTNGP11.phx.gbl...
I have this string:

/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg

If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how would I do this?

In VBScript I could find the first "/" from the back of the sentence, and
cut everything before that, but I'm not shore how to do this in JScript...

The string I want to end up with is Winnie-the-Pooh 1024x768.jpg

Any idea??

Jul 19 '05 #7

P: n/a
Christopher Brandsdal wrote:

/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg

If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg,
how would I do this?


Concisely? This will do:

"/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg".split("/").pop()
-- or: strFilePathName.split("/").pop()

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #8

P: n/a
You'll want to see microsoft.public.scripting.jscript

I've posted a reply in that group and you may need them to help you
adapt the VBScript example that I provided.

David H.
www.gatewayorlando.com

Christopher Brandsdal wrote:
I have this string:

/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg

If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how would
I do this?

In VBScript I could find the first "/" from the back of the sentence, and
cut everything before that, but I'm not shore how to do this in JScript...

The string I want to end up with is Winnie-the-Pooh 1024x768.jpg

Any idea??


Jul 19 '05 #9

P: n/a
"Christopher Brandsdal" wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
: /sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg
:
: If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how
would
: I do this?
:
: In VBScript I could find the first "/" from the back of the sentence, and
: cut everything before that, but I'm not shore how to do this in JScript...
:
: The string I want to end up with is Winnie-the-Pooh 1024x768.jpg

Simple enough...

http://kiddanger.com/lab/xname.html

HTH...

--
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
Jul 19 '05 #10

P: n/a
Good question..
Im working on an JScript application which is old, and not made by me...
I have plans to convert it to VBScript, but with 50.000 lines of code, this
takes time...
But I WILL get a JScript documentation :)

"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> skrev i melding
news:uI**************@TK2MSFTNGP09.phx.gbl...
Pretty much the same as VBScript.

var s = "/sites/foo/bar.jpg";
Response.Write(s.substring(s.lastIndexOf("/")+1, s.length));

So let me ask, if you're more comfortable with VBScript, why are you
continuing to use JScript... or why don't you have JScript documentation
handy?

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Christopher Brandsdal" <br*******@binaer.no> wrote in message
news:#p**************@TK2MSFTNGP11.phx.gbl...
I have this string:

/sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg

If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how

would
I do this?

In VBScript I could find the first "/" from the back of the sentence, and cut everything before that, but I'm not shore how to do this in JScript...
The string I want to end up with is Winnie-the-Pooh 1024x768.jpg

Any idea??


Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.