473,396 Members | 2,139 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,396 software developers and data experts.

Strip Query String from url

Below is a script I use to strip everything from a url except the actual
page. So for example, "http://www.cnn.com/mypage.asp?article=5&id=20"
becomes "mypage.asp".

I'm looking for a script that will strip any querystring from a url if it
exists, so my result would be "http://www.cnn.com/mypage.asp".

Can someone help me modify my script below to achieve this result? I'm
horrible with string functions.
CODE to Get URL **************

Right(Request.ServerVariables("SCRIPT_NAME"),Len(R equest.ServerVariables("SCRIPT_NAME"))-InStrRev(Request.ServerVariables("SCRIPT_NAME"),"/"))
Sep 3 '06 #1
8 5212
Scott wrote on 03 sep 2006 in microsoft.public.inetserver.asp.general:
"http://www.cnn.com/mypage.asp?article=5&id=20"

I'm looking for a script that will strip any querystring from a url if
it exists, so my result would be "http://www.cnn.com/mypage.asp".
<% 'vbscript
t = "http://www.cnn.com/mypage.asp"
response.write stripFromQmark(t)
%>

<script runat='server' language='jscript'>
function stripFromQmark(x){
return x.replace(/\?.*/,'')
}
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 3 '06 #2
"Scott" <sb*****@mileslumber.comwrote in message
news:#M**************@TK2MSFTNGP02.phx.gbl...
Below is a script I use to strip everything from a url except the actual
page. So for example, "http://www.cnn.com/mypage.asp?article=5&id=20"
becomes "mypage.asp".

I'm looking for a script that will strip any querystring from a url if it
exists, so my result would be "http://www.cnn.com/mypage.asp".

Can someone help me modify my script below to achieve this result? I'm
horrible with string functions.
CODE to Get URL **************

Right(Request.ServerVariables("SCRIPT_NAME"),Len(R equest.ServerVariables("SC
RIPT_NAME"))-InStrRev(Request.ServerVariables("SCRIPT_NAME"),"/"))
Dim strRSV
strRSV = Request.ServerVariables("SCRIPT_NAME")
Dim strURL
strURL = Left(strRSV,InStr(strRSV,"?") -1)
Sep 3 '06 #3
Thank you.

"McKirahan" <Ne**@McKirahan.comwrote in message
news:xL******************************@comcast.com. ..
"Scott" <sb*****@mileslumber.comwrote in message
news:#M**************@TK2MSFTNGP02.phx.gbl...
>Below is a script I use to strip everything from a url except the actual
page. So for example, "http://www.cnn.com/mypage.asp?article=5&id=20"
becomes "mypage.asp".

I'm looking for a script that will strip any querystring from a url if it
exists, so my result would be "http://www.cnn.com/mypage.asp".

Can someone help me modify my script below to achieve this result? I'm
horrible with string functions.
CODE to Get URL **************

Right(Request.ServerVariables("SCRIPT_NAME"),Len(R equest.ServerVariables("SC
RIPT_NAME"))-InStrRev(Request.ServerVariables("SCRIPT_NAME"),"/"))
Dim strRSV
strRSV = Request.ServerVariables("SCRIPT_NAME")
Dim strURL
strURL = Left(strRSV,InStr(strRSV,"?") -1)


Sep 4 '06 #4

"Scott" <sb*****@mileslumber.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Below is a script I use to strip everything from a url except the actual
page. So for example, "http://www.cnn.com/mypage.asp?article=5&id=20"
becomes "mypage.asp".

I'm looking for a script that will strip any querystring from a url if it
exists, so my result would be "http://www.cnn.com/mypage.asp".

Can someone help me modify my script below to achieve this result? I'm
horrible with string functions.
CODE to Get URL **************

Right(Request.ServerVariables("SCRIPT_NAME"),Len(R equest.ServerVariables("SC
RIPT_NAME"))-InStrRev(Request.ServerVariables("SCRIPT_NAME"),"/"))
>
The SCRIPT_NAME server variable does not contain query string. Nor does it
contain protocol or host name it only contains the absolute virtual path to
the script.

Sep 4 '06 #5
Scott wrote:
Below is a script I use to strip everything from a url
except the actual page. So for example,
"http://www.cnn.com/mypage.asp?article=5&id=20" becomes
"mypage.asp".
If you intend this for a link, simply use this:

<a href="<%=Request.ServerVariables("URL")%>"... </a>

No need to parse anything.


--
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.
Sep 4 '06 #6
Dave Anderson wrote on 04 sep 2006 in
microsoft.public.inetserver.asp.general:
Scott wrote:
>Below is a script I use to strip everything from a url
except the actual page. So for example,
"http://www.cnn.com/mypage.asp?article=5&id=20" becomes
"mypage.asp".

If you intend this for a link, simply use this:

<a href="<%=Request.ServerVariables("URL")%>"... </a>

No need to parse anything.
Certainly, but is it useful to link tot the page itself?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 4 '06 #7
Evertjan. wrote:
Certainly, but is it useful to link tot the page itself?
Yes, especially when the querystring has session-related nonsense in it,
such as the way youtube embeds the search query in subsequent links. Perhaps
I should have written it this way:

<a href="<%=Request.ServerVariables("URL")%>">Permali nk</a>


--
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.
Sep 4 '06 #8
Dave Anderson wrote on 04 sep 2006 in
microsoft.public.inetserver.asp.general:
Evertjan. wrote:
>Certainly, but is it useful to link tot the page itself?

Yes, especially when the querystring has session-related nonsense in
it, such as the way youtube embeds the search query in subsequent
links. Perhaps I should have written it this way:

<a href="<%=Request.ServerVariables("URL")%>">Permali nk</a>
Yes. I see some sense in an inc file with:

<form
action = '<%=Request.ServerVariables("URL")%>'
method = 'get'
>
....

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 4 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: scott | last post by:
I have a field with datetime values like below LISTING 1. Can someone help me write code strip the time part so only values like "7/15/2005" will be left. Note - We must be able to strip dates...
6
by: Mark Miller | last post by:
I have a scheduled job that uses different XSL templates to transform XML and save it to disk. I am having problems with the code below. The problem shows up on both my development machine (Windows...
5
by: dan.j.weber | last post by:
I'm using Python 2.3.5 and when I type the following in the interactive prompt I see that strip() is not working as advertised: >>>s = 'p p:p' >>>s.strip(' :') 'p p:p' Is this just me or...
0
by: Brian Henry | last post by:
I thought this was useful, its a extender i just wrote for the new .NET menu strip and status strip to extend the menu items to add a status message so when a mouse rolls over the item it displays...
1
by: KevinGPO | last post by:
I am wondering about what's the best and easiest way to strip trailing whitespace from every single file in a folder, recursively. I want to write a program/script so that you pass in a folder...
6
by: rtilley | last post by:
s = ' qazwsx ' # How are these different? print s.strip() print str.strip(s) Do string objects all have the attribute strip()? If so, why is str.strip() needed? Really, I'm just curious......
6
by: eight02645999 | last post by:
hi can someone explain strip() for these : 'example' when i did this: 'abcd,words.words'
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....
6
by: Christoph Zwerschke | last post by:
In Python programs, you will quite frequently find code like the following for removing a certain prefix from a string: if url.startswith('http://'): url = url Similarly for stripping...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.