Removing a Querystring Name & Value

Discussion in 'ASP General' started by scott, Jul 29, 2005.

  1. scott

    scott Guest

    Below, I'm trying to remove the querystring name& value of "catID=12".
    I mananged to isolate the RESULTS part, but I need to be able to strip the
    querystring name and it's value, no matter if the value is 1, 2 or 3 digits.
    I chose to isolate the part I'd be removing below because I know I can take
    it
    and run a replace and get correct string, although I hardcoded the qs name.

    Basically, I'd like to end up with a function that I could just pass the
    name of the querystring and the function would remove the qs name and it's
    value.

    One other issue, if the querystring name and value are the only part of the
    querystring, I need to delete the "?" within the qs.

    Any help?

    CODE:

    sQueryString = "millID=2&catID=12"

    iMarker = InStr(sQueryString ,"catID")
    mystring= Right(sQueryString ,Len(sQueryString )-iMarker+1)


    RESULTS:
    mystring=catID=1
    scott, Jul 29, 2005
    #1
    1. Advertising

  2. "scott" <> wrote in message
    news:...
    > Below, I'm trying to remove the querystring name& value of "catID=12".
    > I mananged to isolate the RESULTS part, but I need to be able to strip the
    > querystring name and it's value, no matter if the value is 1, 2 or 3
    > digits.
    > I chose to isolate the part I'd be removing below because I know I can
    > take it
    > and run a replace and get correct string, although I hardcoded the qs
    > name.
    >
    > Basically, I'd like to end up with a function that I could just pass the
    > name of the querystring and the function would remove the qs name and it's
    > value.
    >
    > One other issue, if the querystring name and value are the only part of
    > the
    > querystring, I need to delete the "?" within the qs.
    >
    > Any help?


    <%
    Function Remove_QS_Parameter(qs, p)
    Dim retVal, re
    Set re = New RegExp
    re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
    retVal = re.Replace(qs,"$2")
    If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
    Remove_QS_Parameter = retVal
    End Function

    CONST qs = "?param1=1&param2=02&param3=003"
    Response.Write Remove_QS_Parameter(qs,"param1") & "<br>"
    Response.Write Remove_QS_Parameter(qs,"param2") & "<br>"
    Response.Write Remove_QS_Parameter(qs,"param3") & "<br>"
    %>
    Chris Hohmann, Jul 29, 2005
    #2
    1. Advertising

  3. scott

    scott Guest

    here's results below: why the paragraph mark? also results are close, but
    not right. can you correct, i can't fix your code.


    qs: ?param1=1¶m2=02¶m3=003

    results:
    ?param2=02¶m3=003
    ?param1=1¶m3=003
    ?param1=1¶m2=02




    "Chris Hohmann" <> wrote in message
    news:u$...
    > "scott" <> wrote in message
    > news:...
    >> Below, I'm trying to remove the querystring name& value of "catID=12".
    >> I mananged to isolate the RESULTS part, but I need to be able to strip
    >> the
    >> querystring name and it's value, no matter if the value is 1, 2 or 3
    >> digits.
    >> I chose to isolate the part I'd be removing below because I know I can
    >> take it
    >> and run a replace and get correct string, although I hardcoded the qs
    >> name.
    >>
    >> Basically, I'd like to end up with a function that I could just pass the
    >> name of the querystring and the function would remove the qs name and
    >> it's
    >> value.
    >>
    >> One other issue, if the querystring name and value are the only part of
    >> the
    >> querystring, I need to delete the "?" within the qs.
    >>
    >> Any help?

    >
    > <%
    > Function Remove_QS_Parameter(qs, p)
    > Dim retVal, re
    > Set re = New RegExp
    > re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
    > retVal = re.Replace(qs,"$2")
    > If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
    > Remove_QS_Parameter = retVal
    > End Function
    >
    > CONST qs = "?param1=1&param2=02&param3=003"
    > Response.Write Remove_QS_Parameter(qs,"param1") & "<br>"
    > Response.Write Remove_QS_Parameter(qs,"param2") & "<br>"
    > Response.Write Remove_QS_Parameter(qs,"param3") & "<br>"
    > %>
    >
    scott, Jul 29, 2005
    #3
  4. scott

    scott Guest

    my browser is showing paragraph marks where ampersand marks should be, and
    formula is wrong.


    "Chris Hohmann" <> wrote in message
    news:u$...
    > "scott" <> wrote in message
    > news:...
    >> Below, I'm trying to remove the querystring name& value of "catID=12".
    >> I mananged to isolate the RESULTS part, but I need to be able to strip
    >> the
    >> querystring name and it's value, no matter if the value is 1, 2 or 3
    >> digits.
    >> I chose to isolate the part I'd be removing below because I know I can
    >> take it
    >> and run a replace and get correct string, although I hardcoded the qs
    >> name.
    >>
    >> Basically, I'd like to end up with a function that I could just pass the
    >> name of the querystring and the function would remove the qs name and
    >> it's
    >> value.
    >>
    >> One other issue, if the querystring name and value are the only part of
    >> the
    >> querystring, I need to delete the "?" within the qs.
    >>
    >> Any help?

    >
    > <%
    > Function Remove_QS_Parameter(qs, p)
    > Dim retVal, re
    > Set re = New RegExp
    > re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
    > retVal = re.Replace(qs,"$2")
    > If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
    > Remove_QS_Parameter = retVal
    > End Function
    >
    > CONST qs = "?param1=1&param2=02&param3=003"
    > Response.Write Remove_QS_Parameter(qs,"param1") & "<br>"
    > Response.Write Remove_QS_Parameter(qs,"param2") & "<br>"
    > Response.Write Remove_QS_Parameter(qs,"param3") & "<br>"
    > %>
    >
    scott, Jul 29, 2005
    #4
  5. "scott" <> wrote in message
    news:...
    > here's results below: why the paragraph mark? also results are close, but
    > not right. can you correct, i can't fix your code.
    >
    >
    > qs: ?param1=1¶m2=02¶m3=003
    >
    > results:
    > ?param2=02¶m3=003
    > ?param1=1¶m3=003
    > ?param1=1¶m2=02


    My code is fine. However, you may be cutting and pasting in a non-standard
    way such that the paste operation is interpreting the occurrences of "&para"
    as the paragraph entity character. Try the following:

    1. Open Outlook Express and highlight the code I provided
    2. Hit CTRL+C to copy the text into the copy/paste buffer
    3. Open Notepad
    4. Hit CTRL+V to paste the copied text into the Notepad window.
    5. Hit CTRL+S to save the file. Save the file with a ".asp" extension and
    place it somewhere in your web directory
    6. Open Internet Explorer and navigate to the newly saved file.
    7. Report back on whether or not this solves your problem.
    Chris Hohmann, Jul 29, 2005
    #5
  6. scott

    scott Guest

    this is results after changing the qs name, your previous code rendered
    paragraph marks. see the problem?

    i'm a quadraplegic, i'm in a hospital, can you help me fix a function as
    described before? it's really hard for me to type.

    ?myparam2=02&myparam3=003
    ?myparam1=1&myparam3=003
    ?myparam1=1&myparam2=02



    "Chris Hohmann" <> wrote in message
    news:...
    > "scott" <> wrote in message
    > news:...
    >> here's results below: why the paragraph mark? also results are close, but
    >> not right. can you correct, i can't fix your code.
    >>
    >>
    >> qs: ?param1=1¶m2=02¶m3=003
    >>
    >> results:
    >> ?param2=02¶m3=003
    >> ?param1=1¶m3=003
    >> ?param1=1¶m2=02

    >
    > My code is fine. However, you may be cutting and pasting in a non-standard
    > way such that the paste operation is interpreting the occurrences of
    > "&para" as the paragraph entity character. Try the following:
    >
    > 1. Open Outlook Express and highlight the code I provided
    > 2. Hit CTRL+C to copy the text into the copy/paste buffer
    > 3. Open Notepad
    > 4. Hit CTRL+V to paste the copied text into the Notepad window.
    > 5. Hit CTRL+S to save the file. Save the file with a ".asp" extension and
    > place it somewhere in your web directory
    > 6. Open Internet Explorer and navigate to the newly saved file.
    > 7. Report back on whether or not this solves your problem.
    >
    scott, Jul 29, 2005
    #6
  7. "scott" <> wrote in message
    news:...
    > this is results after changing the qs name, your previous code rendered
    > paragraph marks. see the problem?
    >
    > i'm a quadraplegic, i'm in a hospital, can you help me fix a function as
    > described before? it's really hard for me to type.
    >
    > ?myparam2=02&myparam3=003
    > ?myparam1=1&myparam3=003
    > ?myparam1=1&myparam2=02


    I'm sorry to here about your condition. I can empathize as I am also
    disabled and have spent considerable time hospitalized. Would it be possible
    for you to show my previous reply to a nurse, aide or a computer savvy
    visitor? Cutting and pasting the code I provided should be a simple
    procedure for anyone who has even a small bit of experience with computers.
    I would also strongly recommend that you speak with an occupational
    therapist about getting adaptive technologies to facilitate the use of
    computers.
    Chris Hohmann, Jul 29, 2005
    #7
  8. scott

    scott Guest

    i pasted ascii text chris. it's listed below. i'm a c5/c6 quad, just asking
    for a little professional courtesy. if you can't fix your code, thanks
    anyway.

    i'll repost.



    your code:


    <%
    Function Remove_QS_Parameter(qs, p)
    Dim retVal, re
    Set re = New RegExp
    re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
    retVal = re.Replace(qs,"$2")
    If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
    Remove_QS_Parameter = retVal
    End Function

    CONST qs = "?myparam1=1&myparam2=02&myparam3=003"

    Response.Write Remove_QS_Parameter(qs,"myparam1") & "<br>"
    Response.Write Remove_QS_Parameter(qs,"myparam2") & "<br>"
    Response.Write Remove_QS_Parameter(qs,"myparam3") & "<br>"
    %>


    YOUR RESULTS;


    ?myparam2=02&myparam3=003
    ?myparam1=1&myparam3=003
    ?myparam1=1&myparam2=02








    "Chris Hohmann" <> wrote in message
    news:...
    > "scott" <> wrote in message
    > news:...
    >> this is results after changing the qs name, your previous code rendered
    >> paragraph marks. see the problem?
    >>
    >> i'm a quadraplegic, i'm in a hospital, can you help me fix a function as
    >> described before? it's really hard for me to type.
    >>
    >> ?myparam2=02&myparam3=003
    >> ?myparam1=1&myparam3=003
    >> ?myparam1=1&myparam2=02

    >
    > I'm sorry to here about your condition. I can empathize as I am also
    > disabled and have spent considerable time hospitalized. Would it be
    > possible for you to show my previous reply to a nurse, aide or a computer
    > savvy visitor? Cutting and pasting the code I provided should be a simple
    > procedure for anyone who has even a small bit of experience with
    > computers. I would also strongly recommend that you speak with an
    > occupational therapist about getting adaptive technologies to facilitate
    > the use of computers.
    >
    scott, Jul 30, 2005
    #8
  9. "scott" <> wrote in message
    news:%...
    >i pasted ascii text chris. it's listed below. i'm a c5/c6 quad, just asking
    >for a little professional courtesy. if you can't fix your code, thanks
    >anyway.
    >
    > i'll repost.
    >
    >
    >
    > your code:
    >
    >
    > <%
    > Function Remove_QS_Parameter(qs, p)
    > Dim retVal, re
    > Set re = New RegExp
    > re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
    > retVal = re.Replace(qs,"$2")
    > If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
    > Remove_QS_Parameter = retVal
    > End Function
    >
    > CONST qs = "?myparam1=1&myparam2=02&myparam3=003"
    >
    > Response.Write Remove_QS_Parameter(qs,"myparam1") & "<br>"
    > Response.Write Remove_QS_Parameter(qs,"myparam2") & "<br>"
    > Response.Write Remove_QS_Parameter(qs,"myparam3") & "<br>"
    > %>
    >
    >
    > YOUR RESULTS;
    >
    >
    > ?myparam2=02&myparam3=003
    > ?myparam1=1&myparam3=003
    > ?myparam1=1&myparam2=02


    Sigh. I'd be happy to "fix" my code. Just tell me what's wrong with it.
    Otherwise, you probably are better off reposting, since I am obviously
    missing something. Good luck.
    Chris Hohmann, Jul 30, 2005
    #9
  10. scott

    scott Guest

    no, it is i who have missed something, i deeply apologize for temporary
    stupidity. the medication is affecting my brain more than i thought.


    "Chris Hohmann" <> wrote in message
    news:%...
    > "scott" <> wrote in message
    > news:%...
    >>i pasted ascii text chris. it's listed below. i'm a c5/c6 quad, just
    >>asking for a little professional courtesy. if you can't fix your code,
    >>thanks anyway.
    >>
    >> i'll repost.
    >>
    >>
    >>
    >> your code:
    >>
    >>
    >> <%
    >> Function Remove_QS_Parameter(qs, p)
    >> Dim retVal, re
    >> Set re = New RegExp
    >> re.Pattern = "(\?|&)" & p & "=.*?(&|$)"
    >> retVal = re.Replace(qs,"$2")
    >> If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
    >> Remove_QS_Parameter = retVal
    >> End Function
    >>
    >> CONST qs = "?myparam1=1&myparam2=02&myparam3=003"
    >>
    >> Response.Write Remove_QS_Parameter(qs,"myparam1") & "<br>"
    >> Response.Write Remove_QS_Parameter(qs,"myparam2") & "<br>"
    >> Response.Write Remove_QS_Parameter(qs,"myparam3") & "<br>"
    >> %>
    >>
    >>
    >> YOUR RESULTS;
    >>
    >>
    >> ?myparam2=02&myparam3=003
    >> ?myparam1=1&myparam3=003
    >> ?myparam1=1&myparam2=02

    >
    > Sigh. I'd be happy to "fix" my code. Just tell me what's wrong with it.
    > Otherwise, you probably are better off reposting, since I am obviously
    > missing something. Good luck.
    >
    scott, Jul 30, 2005
    #10
  11. "scott" <> wrote in message
    news:%23$...
    > no, it is i who have missed something, i deeply apologize for temporary
    > stupidity. the medication is affecting my brain more than i thought.


    No problem. Please don't hesitate to post again if you have any other
    questions. I look forward to helping if I am able.

    Yours in respect and friendship,
    Chris Hohmann
    Chris Hohmann, Aug 1, 2005
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon
    Replies:
    3
    Views:
    23,717
    bruce barker
    Feb 9, 2004
  2. Mehdi
    Replies:
    6
    Views:
    36,065
    sloan
    Apr 6, 2006
  3. John Davis
    Replies:
    2
    Views:
    373
    Dave Anderson
    Aug 18, 2003
  4. scott

    Removing a Querystring Name & Value

    scott, Jul 28, 2005, in forum: ASP General
    Replies:
    0
    Views:
    99
    scott
    Jul 28, 2005
  5. Adeel Ahmad
    Replies:
    1
    Views:
    340
    Anthony Jones
    Mar 7, 2006
Loading...

Share This Page