String manipulation of a URL - strip preceding characters?

Ask a Question related to ASP, Design and Development.

  1. #1

    Default 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:

    [url]http://www.essermanyachtsales.com/riverbend/[/url]

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

    "Riverbend"

    Many thanks

    Jason



    jason Guest

  2. Similar Questions and Discussions

    1. How to strip of characters when long text is displayed?
      Hi, I was wondering if anyone had some function or has had to strip off characters from a long string. We have a user inteface, and the text is...
    2. String manipulation
      Hi! I am trying to figure out a simple, Perl way to break down any sting similar to the following: $s0 =...
    3. How to strip HTML markup from string?
      Hello, I want to transform text with HTML markup to plain text. Is there some simple way how to do it? I can surely write my own function,...
    4. Should String#strip take a parameter?
      All, Several times I have run across the need to strip characters other than whitespaces from the beginning and/or end of a string. I have...
    5. Strip Leading Characters ??
      I'd like to strip various leading characters from a registration number. for example MA1234 = 1234 987651 = 987651 Q10001 = 10001 The code...
  3. #2

    Default Re: String manipulation of a URL - strip preceding characters?

    url = "http://www.essermanyachtsales.com/riverbend/"
    url = split(url, "/"): response.write url(3)



    "jason" <jason@catamaranco.com> wrote in message
    news:OYASKvSUDHA.1724@TK2MSFTNGP10.phx.gbl...
    > How would I strip out everything from before the last "/" in the following
    > string generated from request.servervaraibles method:
    >
    > [url]http://www.essermanyachtsales.com/riverbend/[/url]
    >
    > ...so that I was just left with:
    >
    > "Riverbend"
    >
    > Many thanks
    >
    > Jason
    >
    >
    >

    Aaron Bertrand - MVP Guest

  4. #3

    Default Re: String manipulation of a URL - strip preceding characters?

    jason wrote:
    > How would I strip out everything from before the last "/" in the
    > following string generated from request.servervaraibles method:
    >
    > [url]http://www.essermanyachtsales.com/riverbend/[/url]
    >
    > ...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


    Bob Barrows Guest

  5. #4

    Default Re: String manipulation of a URL - strip preceding characters?

    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


    Bob Barrows Guest

  6. #5

    Default Re: String manipulation of a URL - strip preceding characters?

    > > 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." :-)


    Aaron Bertrand - MVP Guest

  7. #6

    Default Re: String manipulation of a URL - strip preceding characters?

    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" <aaron@TRASHaspfaq.com> wrote in message
    news:ecHtFKTUDHA.3700@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." :-)
    >
    >

    jason Guest

  8. #7

    Default Re: String manipulation of a URL - strip preceding characters?

    Thanks


    "Bob Barrows" <reb_01501@yahoo.com> wrote in message
    news:O7cT8FTUDHA.2420@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
    >
    >

    jason Guest

  9. #8

    Default Re: String manipulation of a URL - strip preceding characters?

    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" <aaron@TRASHaspfaq.com> wrote in message
    news:ecHtFKTUDHA.3700@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." :-)
    >
    >

    jason Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139