删除查询字符串名称&值 [英] Removing a Querystring Name & Value
问题描述
下面,我正在尝试删除查询字符串名称& catID = 12的值。
我自行隔离了RESULTS部分,但我需要能够剥离
查询字符串名称及其值,无论价值是1,2或3位数。
我选择隔离下面我要删除的部分因为我知道我可以带
它
并运行一个替换并获得正确的字符串,虽然我硬编码了qs名称。
基本上,我想最终得到一个函数我只能传递查询字符串的
名称,该函数将删除qs名称,并且它的价值为
。
另一个问题,如果查询字符串名称和值是
查询字符串的唯一部分,我需要删除?在qs内。
任何帮助?
代码:
sQueryString =" millID = 2& catID = 12"
iMarker = InStr(sQueryString," catID")
mystring = Right(sQueryString,Len(sQueryString)-iMarker +1)
结果:
mystring = catID = 1
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
推荐答案
"斯科特" < SC *** @ sbailey.com>在消息中写道
news:eC ************** @ tk2msftngp13.phx.gbl ...
"scott" <sc***@sbailey.com> wrote in message
news:eC**************@tk2msftngp13.phx.gbl...
下面,我是'我试图删除查询字符串名称& catID = 12的值。
我管理它来隔离RESULTS部分,但是我需要能够去除
查询字符串名称及其值,无论值是1 ,2或3
数字。
我选择隔离我将要删除的部分,因为我知道我可以把它拿走
并运行替换并获得正确的字符串虽然我硬编了qs
名称。
基本上,我想最终得到一个函数,我可以传递查询字符串和函数的名称将删除qs名称及其值
另一个问题,如果查询字符串名称和值是
查询字符串的唯一部分,我需要删除?在qs内。
任何帮助?
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?
<%
函数Remove_QS_Parameter(qs,p)
Dim retVal,重新
设置re =新RegExp
re.Pattern ="(\?|&)" &安培; p& " =。*?(& |
<%
Function Remove_QS_Parameter(qs, p)
Dim retVal, re
Set re = New RegExp
re.Pattern = "(\?|&)" & p & "=.*?(&|
)"
retVal = re.Replace(qs,"
)"
retVal = re.Replace(qs,"
2")
如果左(retVal,1)="&"然后retVal ="?" &安培;中(retVal,2)
Remove_QS_Parameter = retVal
结束函数
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>"
%>
2")
If Left(retVal,1) = "&" Then retVal = "?" & Mid(retVal,2)
Remove_QS_Parameter = retVal
End Function
CONST qs = "?param1=1¶m2=02¶m3=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>"
%>
这篇关于删除查询字符串名称&值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!